jhy
jhy

Reputation: 233

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.

Upvotes: 14

Views: 27557

Answers (3)

Übend
Übend

Reputation: 71

I had the problem with PySide6, not with PyQt5. With PySide6 I got rid of the message by removing the Slot()-decorators.

Upvotes: 0

AB Bolim
AB Bolim

Reputation: 2125

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.

Upvotes: 24

prajmus
prajmus

Reputation: 3269

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.

Upvotes: 9

Related Questions