I understand very well the benefits and drawbacks of using the new syntax for connecting slots in Qt 5. Just to mention some:
Pros:
- Compile time checks (the slots exists, compatible arguments...)
- Possibility to use lambdas (useful for very short and specific slots)
- Protecting private/protected slots from being called from outside the class (ref)
Contras:
- More complicate syntax in certain cases (specially overloads)
- No support for slots with arguments with a default value
I also know that there are some (very few) cases where it is not possible (yet) to use the new syntax (QFileDialog::open
).
Now, for the old syntax we had to mark those methods as slots
in their definition, to mark the class with the Q_OBJECT
macro, to moc it, and to inherit from QObject
. As mentioned above, the new syntax doesn't require the methods to me marked as slots.
Is there any advantage of keeping the slots
specifier when using (and only using) the new syntax? If the slots are the only QMetaObject
's featured used by a class, we could then avoid the necessity to mark the class as Q_OBJECT
, or even to inherit from QObject
itself.