分类: LINUX
2013-09-17 21:19:07
QtWarning QMetaObject::connectSlotsByName: No matching signal for on_something_event()
with Google I found a that explained, very clearly, what happens. I'd bet it's somewhere in thedocumentation of Qt, but so far I have not found anything about that in the sections I read.
The fact is that the setupUi() , which is created when you a window using Designer or Qt Creator, does a special on all the functions on_widgetName_eventName() functions and attempts to connect them. This is neat, although it means that if you have a slot that way which is not directly related to a widgetName and a valid eventName for that widget, the connect() call fails and you that at runtime.
You have two solutions here:
1) Rename your functions to not use on_... as the introducer (i.e. you could use slot_... instead, or the Qt naming convention such as onName1Name2()...)
2) Rename your functions so the -connect happens as expected!
In the second case, you need to rename the to match the widget exactly and then the exactly. For example, if you have a QPushButton clickHere, you could a :
on_clickHere_clicked()
and that will be called any the clicks your clickHere (and of course you don't have to do the connect yourselves.)