Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QMetaObject::connectSlotsByName: No matching signal

I set a QT menu, which is automatically connected with action function on_actionOpen_triggered(). Later I want to pass a filename string to this function in order to call this function manually in a special condition. So I changed the function signature to on_actionOpen_triggered( const char *filename_in ). After this change the program is running well, but there is a complain in terminal,

QMetaObject::connectSlotsByName: No matching signal for on_actionOpen_triggered(const char*)

I am wondering what happened, and how I can add arguments for this menu action functions.

Thank you.

like image 279
jhy Avatar asked Jun 22 '14 19:06

jhy


2 Answers

I was facing same Warning/Error QMetaObject::connectSlotsByName: No matching signal for

And got simple solution. For Example:

Problem :
QMetaObject::connectSlotsByName: No matching signal for on_actionOpen_triggered(const char*) Warning You just need to change the name of the Slot

Solution
Change Slot name like on_actionOpenTriggered and this warning disappear.

Hint
Qt try to understand its default slot like on_<name_of_object>_<action>, So if you specify any slot with above signature, Qt will throw warning.

Hope it will help to someone.

like image 62
AB Bolim Avatar answered Nov 18 '22 09:11

AB Bolim


Qt autoconnection mechanism can't find suitable signal to your slot. For menu item there's no signal that would match your slot with one argument, and signal must not have fewer arguments than slot.

You can change slot's name so that it won't try to find a matching signal, and use QObject::connect directly instead of QMetaObject::connectSlotsByName. Moreover you'll have to assign default value to your argument filename_in if you want connect to work with triggeredsignal.

like image 36
prajmus Avatar answered Nov 18 '22 09:11

prajmus