Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SIGNAL - SLOT BUG
QtWS25 Last Chance

SIGNAL - SLOT BUG

Scheduled Pinned Locked Moved General and Desktop
6 Posts 5 Posters 1.5k Views
  • 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 Offline
    J Offline
    JOHN.CHEN
    wrote on last edited by JOHN.CHEN
    #1

    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 ?

    jsulmJ 1 Reply Last reply
    0
    • joeQJ Offline
      joeQJ Offline
      joeQ
      wrote on last edited by
      #2

      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
      2
      • J 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 ?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by jsulm
        #3

        @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
        1
        • jsulmJ 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!

          J Offline
          J Offline
          JOHN.CHEN
          wrote on last edited by
          #4

          @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.sueM 1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            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
            0
            • J JOHN.CHEN

              @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.sueM Offline
              m.sueM Offline
              m.sue
              wrote on last edited by m.sue
              #6

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

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved