Interface sharing in Qt

I always try to apply SOLID principles, and I really like the Qt toolkit, but I'm always in standby mode using the single inheritance rule .

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

How do you combine single inheritance from the QObject rule and the principle of segment separation.
I want to define interfaces with signals and slots, but I am not allowed to do this.

How do you get around this shortcoming?

+4
source share
2 answers

Keep in mind that signals and slots are nothing but functions that have special behavior. This way you can use them to create interfaces.

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

+5
source

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

+1
source

All Articles