Problem with connect() (enum-type as parameter)
Hi all,
the call of QObject::connect() in my program fails at runtime with the following message:
"Object::connect: No such slot Monitor::testSlot()"
If I leave out the parameters from the slots definition it works.
The types of the parameters are std::string and an enum-type.
Do I have to register the enum-type with qRegisterMetaType() ?
I tried, but it seems to make no difference. The same error still occurs.
What else can be the reason for this error?
Thanks in advance
Alu
Re: Problem with connect() (enum-type as parameter)
The enum should be registered using Q_ENUM, but I'm not sure if this is your problem. When do you get the above error message? When you pass parameters or not?
Re: Problem with connect() (enum-type as parameter)
I get the error when parameters are passed.
When I use uint instead of the enum-type it works.
The strange thing is: I call QObject::connect() in another part of the program -- with the same enum-type as argument to signals and slots -- and there's no error message. But this connections don't work. Nothing happens after the signal is emitted!?
(The only difference is that it is a direct connection (within one thread) in this case and a queued connection (between two threads) in the case described in the first post.)
Is this all the same error or is it about two different issues?
Alu
EDIT: After another critical view it turned out that none of the connects works right. In the second case the connect returns false, but no error message occurs.
Re: Problem with connect() (enum-type as parameter)
Queued connections require parameters to be serialized, so you have to use Q_ENUM to create a meta-type for the enum and then use qRegisterMetaType to register it with QVariant. Anyway the error you get implies you pass the slot signature without parameters, so I suggest you check your connect() code - make sure the slot is declared as a slot and everything else is in place.