• I find a bug for signal and slot :

    signal function define in a thread class:
    private slots:
    void RefreshUI(UCHAR uCmd);

    signal-slot connect :

    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 function

    signal-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);

  • Moderators

    @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
    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)

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    As @jsulm wrote, you have to register your custom type even if it's "just" a typedef, you have to make it known to the Qt meta type system.


    UCHAR define -->QT TYPE (typedef unsigned char UCHAR)

    the type uchar is defined by Qt not UCHAR.
    UCHAR is defined by the WINDOWS SDK.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.