Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    SIGNAL - SLOT BUG

    General and Desktop
    5
    6
    1055
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      JOHN.CHEN last edited by JOHN.CHEN

      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 ?

      jsulm 1 Reply Last reply Reply Quote 0
      • joeQ
        joeQ last edited by

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

        Just do it!

        1 Reply Last reply Reply Quote 2
        • jsulm
          jsulm Lifetime Qt Champion @JOHN.CHEN last edited by jsulm

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

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          J 1 Reply Last reply Reply Quote 1
          • J
            JOHN.CHEN @jsulm last edited by

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

            m.sue 1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              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.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply Reply Quote 0
              • m.sue
                m.sue @JOHN.CHEN last edited by m.sue

                @JOHN.CHEN said in SIGNAL - SLOT BUG:

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

                Hi,
                the type uchar is defined by Qt not UCHAR.
                UCHAR is defined by the WINDOWS SDK.
                -Michael.

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post