Reputation: 2774
I have spent some time with finding an error, in connection wit slots and signals. I copied some connect() lines from another file, and I relied on the compiler to find out which objects I need to define in my new class, so I added them. The 'this' object should not be edited, so I did not care providing the corresponding slots. The program compiles OK, an even without warnigns. But -in lack of slots- does not run.
Considering the (sometimes too) strict type checking, why does not produce Qt at least a warning? (at compile time it can know for sure, that no such slot exists.)
Upvotes: 1
Views: 233
Reputation: 913
Actually, new functor-based connections does checking at compile-time, so in case of some invalid signal/slot the app will not even compile
So, to check it during compile time you just need to use functor-based type of connection:
connect(slider, &QSlider::valueChanged,
doubleSpinBox, &QDoubleSpinBox::setValue);
instead of string-based:
connect(slider, SIGNAL(valueChanged(int)),
doubleSpinBox, SLOT(setValue(int)));
You can read here in details: http://doc.qt.io/qt-5/signalsandslots-syntaxes.html
Upvotes: 5