Details
-
Suggestion
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
None
-
None
Description
The new (and old) connection syntax is too verbose:
connect(sender, &Sender::valueChanged, receiver, &Receiver::updateValue );
Even more so when overloads have to be explicitly specified:
connect(spinbox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), slider, &QSlider::setValue);
A possible solution, use a macro + MOC to generate the connection statement from a simpler expression:
Q_CONNECT(spinbox->valueChanged(int), slider->setValue)
Example features:
- detect if a pointer is used "objPtr->someSig" or an instance "obj.someSig" and use the & operator in case of the latter, less prone to errors
- detect if overload is specified with signal or slot parameter(s) and use static_cast to specify it
- make it work with non QObject derived classes methods, free functions and lambdas too, and from outside the scope of a QObject derived classes