Nobody's mentioned that Qt4-style connect syntax is required to solve the
diamond inheritance problem that frequently appears when using a
signals/slots interface.

Ex:

class Interface
{
public:
    virtual QObject* asQObject()=0;
protected: //signals
    virtual void someSignal()=0;
public: //slots
    virtual void someSlot()=0;
};
class A : public QObject, public Interface
{
Q_OBJECT
public:
    QObject* asQObject() { return this; }
signals:
    void someSignal();
public slots:
    void someSlot();
};
class B : public QObject, public Interface
{
Q_OBJECT
public:
    QObject* asQObject() { return this; }
signals:
    void someSignal();
public slots:
    void someSlot();
};

int main()
{
    Interface *a = new A;
    Interface *b = new B;
    connect(a->asQObject(), SIGNAL(someSignal()), b->asQObject(),
SLOT(someSlot())); //not possible using Qt5 style connect syntax, because
someSignal and someSlot are not members of QObject
}


^code is pseudo/buggy, but mostly correct. also I'm aware that this
oversimplified example wouldn't suffer from the diamond inheritance
problem... but the diamond inheritance problem does frequently show up when
using signals/slots interfaces, so the above is usually what a solution
looks like


d3fault
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to