SIGNAL - SLOT BUG
-
I find a bug for signal and slot :
signal function define in a thread class:
private slots:
void RefreshUI(UCHAR uCmd);signal-slot connect :
connect(m_pDT,SIGNAL(RefreshUI(UCHAR)),this,SLOT(UpdataUI(UCHAR)),QT::QueuedConnection);slot funcion define in a Widget class:
void UpdataUI(UCHAR uCmd);if you call emit RefreshUI(3) UpdataUI() function doesn't trigger. but if you alter the parameter type for int or other type , not is UCHAR ,UpdataUI() function can be trigger, Do you meet it ?
-
Hi , friend, You used the wrong way!
private slots:
void RefreshUI(UCHAR uCmd); // this is slot functionsignal-slot connect :
connect(m_pDT,SIGNAL(RefreshUI(UCHAR)),this,SLOT(UpdataUI(UCHAR)),QT::QueuedConnection); // this is wrong way.connect( signalObj ,SIGNAL(UpdataUI(UCHAR)), slotObj, SLOT(RefreshUI(UCHAR)), QT::QueuedConnection);
-
I find a bug for signal and slot :
signal function define in a thread class:
private slots:
void RefreshUI(UCHAR uCmd);signal-slot connect :
connect(m_pDT,SIGNAL(RefreshUI(UCHAR)),this,SLOT(UpdataUI(UCHAR)),QT::QueuedConnection);slot funcion define in a Widget class:
void UpdataUI(UCHAR uCmd);if you call emit RefreshUI(3) UpdataUI() function doesn't trigger. but if you alter the parameter type for int or other type , not is UCHAR ,UpdataUI() function can be trigger, Do you meet it ?
@JOHN.CHEN It is not a bug. If you use custom data types like UCHAR you need to register them, so Qt can use them for signals/slots. See http://doc.qt.io/qt-5.7/custom-types.html
Also you should check the return value which is returned by connect(). It returns false if it could not connect. And if the connection fails you will see a warning in the console.
And you're using signals/slots wrong: void RefreshUI(UCHAR uCmd) is a slot but you use it like a signal! -
@JOHN.CHEN It is not a bug. If you use custom data types like UCHAR you need to register them, so Qt can use them for signals/slots. See http://doc.qt.io/qt-5.7/custom-types.html
Also you should check the return value which is returned by connect(). It returns false if it could not connect. And if the connection fails you will see a warning in the console.
And you're using signals/slots wrong: void RefreshUI(UCHAR uCmd) is a slot but you use it like a signal!@jsulm said in SIGNAL - SLOT BUG:
hUI(UCHAR uCmd) is a slot but you use it lik
just i modify the signal and slot function's parameter type for int type or long type,it's ok . only UCHAR type is not tigger . UCHAR define -->QT TYPE (typedef unsigned char UCHAR)
-
@jsulm said in SIGNAL - SLOT BUG:
hUI(UCHAR uCmd) is a slot but you use it lik
just i modify the signal and slot function's parameter type for int type or long type,it's ok . only UCHAR type is not tigger . UCHAR define -->QT TYPE (typedef unsigned char UCHAR)
@JOHN.CHEN said in SIGNAL - SLOT BUG:
UCHAR define -->QT TYPE (typedef unsigned char UCHAR)
Hi,
the typeuchar
is defined by Qt notUCHAR
.
UCHAR
is defined by the WINDOWS SDK.
-Michael.