Search code examples
qtinterfacesolid-principlesinterface-segregation-principle

Interface Segregation in Qt


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?


Solution

  • 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.