views:

145

answers:

2

I always try to apply the S.O.L.I.D principles and I really like the Qt toolkit but I find myself stuggeling all the time with the single inheritance rule.

If you are using multiple inheritance, moc assumes that the first inherited class is a subclass of QObject. Also, be sure that only the first inherited class is a QObject.

How do you combine the single inheritance from a QObject rule and the Interface Segregation Principle.
I want to define the interfaces with signals and slots, but I'm not allowed to do this.

How do you get around this shortcomming?

+1  A: 

I don't think you can easily get around that with Qt's signal/slot mechanisms. You could try looking at either boost::signals or the sigc library, which are both more flexible in where you can place signals and slots. Be aware of possible namespace collisions with either library and Qt's signals and slots macros.

Caleb Huitt - cjhuitt
+3  A: 

Keep in mind that signals and slots are nothing more than functions that have special behaviors. Thus, you can use them to create interfaces.

For a full description of the process and a complete workaround for complex cases, see Qt Quarterly #15.

Kaleb Pederson