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 Between main and worker thread

Signal Slot Between main and worker thread

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 438 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.
  • DonCoderD Offline
    DonCoderD Offline
    DonCoder
    wrote on last edited by DonCoder
    #1

    410c7216-70d5-4c1a-9384-34620e084539-image.png

    I have a scenario where object S will emit someThingHappened() signal and Object R have slot HandleOnSomethingHappened().

    I know connect should happen with either Auto or Queued Connection.
    I have verified Q_OBJECT Macro in both classes, even moc files also got generated

    But My slot is not getting exceuted upon emitting the signal.
    Connection have made
    a) in Sender class
    b) in Reveiver Class In both classes i tried separately

    1. What is the mistake am i doing ?
    2. what if the Object S is a static object, Can i connect a static object's signal with a non static object slot ?
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @DonCoder said in Signal Slot Between main and worker thread:

      What is the mistake am i doing ?

      Without code? Does the thread is running it's eventloop?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • DonCoderD Offline
        DonCoderD Offline
        DonCoder
        wrote on last edited by DonCoder
        #3

        @Christian-Ehrlicher How to check whether QThread is running its event loop or not ?

        Also I would like to know
        what if the Object S is a static object, Can i connect a static object's signal with a non static object slot ?

        I will post simplified code soon ...

        JKSHJ 1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @DonCoder said in Signal Slot Between main and worker thread:

          How to check whether QThread is running its event loop or not ?

          Maybe by reading the documentation of QThread and QThread::run()?

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • DonCoderD DonCoder

            @Christian-Ehrlicher How to check whether QThread is running its event loop or not ?

            Also I would like to know
            what if the Object S is a static object, Can i connect a static object's signal with a non static object slot ?

            I will post simplified code soon ...

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            @DonCoder said in Signal Slot Between main and worker thread:

            what if the Object S is a static object, Can i connect a static object's signal with a non static object slot ?

            Don't create static QObjects. This causes problems because static objects are created before main() starts, which conflicts with the requirement that QCoreApplication (or its subclass) must be the very first QObject to be created.

            I know connect should happen with either Auto or Queued Connection.
            I have verified Q_OBJECT Macro in both classes, even moc files also got generated

            Yes, these are both correct and good.

            From @Christian-Ehrlicher's links, you'll find more requirements. In particular:

            1. You must not subclass QThread
            2. You must start() the QThread

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            3

            • Login

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