Hello, 2016-05-07 10:34 GMT+03:00 d3fault <d3faultdot...@gmail.com>:
> ... > > ^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 > I guess you are talking about "virtual inheritance with QObject"? As Meta-Object Compiler docs <http://doc.qt.io/qt-5/moc.html#multiple-inheritance-requires-qobject-to-be-first> says, "Virtual inheritance with QObject <http://doc.qt.io/qt-5/qobject.html> is *not* supported.". But also if you are writing an abstract base class which has a signal and slots, then this abstraction also contains signal and slots mechanism? So even this is ABC, it is also possible to derive from QObject? I am sorry I am not an exprienced C++ or Qt developer but it makes sense to me. So If I were you I would derive my ABCs from QObject class, so my ABCs would have signals as "Qt-ish" and would be able to use new signal and slot syntax. By the way since signals are implemented by the moc, you don't even have to make them virtual, I am not sure but making a virtual signal also is not possible. class Base : public QObject { Q_OBJECT public: explicit Base(QObject *parent = Q_NULLPTR); signals: void signalFoo(); public slots: virtual void slotBar() = 0; }; class Der : public Base { Q_OBJECT public: explicit Der(QObject *parent = Q_NULLPTR); public slots: void slotBar() Q_DECL_OVERRIDE; }; As an example you can research Qt APIs. For example QAbstractItemModel <http://doc.qt.io/qt-5/qabstractitemmodel.html>. It is also ABC but since it uses signals and slots, it also derives from QObject class. Also if you stay in "inland of Qt" you would not have to use RTTI. For learning more about how Qt uses multiple inheritance there is a great article <http://www.ics.com/blog/multiple-inheritance-qt> about it from ICS. Cheers, Sina
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest