PDA

View Full Version : qRegisterMetaType - problems with connect()



Macok
5th March 2009, 23:25
I created my own class and | wanted to pass it as argument in SIGNALS/SLOTS.
But when I call emit signal(myClass); I get this error on output:
Object::connect: Cannot queue arguments of type 'myClass' (Make sure 'myClass' is registered using qRegisterMetaType()I solved the problem by passing pointer to myClass instead of myClass object, but what's wrong in the first method?

faldzip
5th March 2009, 23:55
Qt docs fragment:


. . . Q_DECLARE_METATYPE() doesn't actually register the type; you must still use qRegisterMetaType() for that, particularly if you intend to use the type in signal and slot connections. . .

You have to register your class to Qt meta objects system. To achieve this you need Q_DECLARE_METATYPE macro and qRegisterMetaType() function. Good explanation you can find in Qt docs (Q_DECLARE_METATYPE (http://doc.trolltech.com/4.1/qmetatype.html#Q_DECLARE_METATYPE) and qRegisterMetaType (http://doc.trolltech.com/4.1/qmetatype.html#qRegisterMetaType)).