Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Why is it that on_button_clicked() doesn't need a signal?
Q74r3wq- last edited by
I have a
on_<button objectName>_clicked()slot function and somehow it is triggered every time a button is clicked, without any signals defined.
Now that the button is definitely the most used widget so maybe this is automated under the hood, I still would like know the mechanism, and more importantly which widgets have the same behavior. For example,
QTGraphicsViewdoesn't work this way.
I already consulted the signal-slot page as well as the QTPushButton page but didn't find what I need.
This is done by QMetaObject::connectSlotsByName which is called as part of the you designer ui object setup method.
When you us UI files, the code generated in setupUI calls
which will try to match widgets and slots
hehe one sec too late :)
In any case. Its far better to use connects in the code as this method suffer from easy to break.
if you ever rename your widget or the slot - it stops working. silently.
So for a production-quality app, its best to avoid this feature however handy it is.