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. Emitting signals from std::thread
Forum Updated to NodeBB v4.3 + New Features

Emitting signals from std::thread

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 1.3k Views 2 Watching
  • 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.
  • A Offline
    A Offline
    ajaxcrypto
    wrote on last edited by
    #1

    I have a class A, (which cannot be modified) that accepts a callback which gets called at certain intervals. In order to update the GUI, I register a lambda which emits a signal as my callback. The callback itself runs on a separate thread (std::thread managed by class A). While I can clearly see that the lambda gets called periodically, the slot attached to the emitted signal never gets invoked. What am I doing wrong?

    I do not see any errors in console and the slot/signal hookup is done in GUI thread and I have verified that the connect call successfully connects the signal and slot.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you show the code you use for signal and slots handling ?

      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
      2
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        My guess is that you are blocking the event loop in the thread where the slot should run. do you have an infinite loop running around?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        3
        • A Offline
          A Offline
          ajaxcrypto
          wrote on last edited by
          #4

          As it turns out, a user defined enum class was being emitted as signal. This type needs to be registered. The strange thing was no errors in console however. It is working as intended now.

          1 Reply Last reply
          4

          • Login

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