PDA

View Full Version : use user type in signal function parametrs



sergey_85
2nd December 2009, 10:34
Hi!

In my app defined signal with signature:


enum MsgTypes
{
mtUnknown =0,
mtError,
mtUser
};

class MyClass
{
signals:
void onMessage(QString text, int msgType); //working, signal catched in my app
void onMessage1(QString text, MsgTypes msgType); //bad, not working, signal is not catched in my app
};


how to make signal with user types will be worked

Lykurg
2nd December 2009, 10:55
Hi use qRegisterMetaType/Q_DECLARE_METATYPE.

yogeshgokul
2nd December 2009, 10:56
Hi!

In my app defined signal with signature:


enum MsgTypes
{
mtUnknown =0,
mtError,
mtUser
};

class MyClass
{
signals:
void onMessage(QString text, int msgType); //working, signal catched in my app
void onMessage1(QString text, MsgTypes msgType); //bad, not working, signal is not catched in my app
};


how to make signal with user types will be worked
How can you say its not working. There could several other factors who can affect the connection. Please show that, how your slot looks and how you are connecting the signal slot.
Also please check the return value of CONNECT statement. You may need to register your data type.

squidge
2nd December 2009, 11:08
Check the output window, you may notice an error being output at run time about incompatible signal/slots and such like.

and like yogeshgokul says, we need to see your slot and connect statements.

sergey_85
2nd December 2009, 11:18
Ok! Thank for help!

- add Q_DECLARE_METATYPE(BmsEMsgType)
- edit CONNECT
- edit signals section (change definition)

Now it's work.