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 syncing between two Qthread
Forum Updated to NodeBB v4.3 + New Features

Signal/Slot syncing between two Qthread

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 496 Views 1 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.
  • E Offline
    E Offline
    electro
    wrote on last edited by
    #1

    Hi all,

    In my software, i'm using the QThread::wait(ms) method to wait a slot result of another QThread.

    A summary of my project is the following.
    -The Main thread is MainWindow class basic : public QMainWindow
    -The Second thread is created with the following method and this object is created with comm_modules class : public QObject

    The second thread or objet is created in the main thread constructor.

    Second Thread constructor :

    comm_modules(){
        _thread = new QThread;
        moveToThread(_thread);
        _thread->start();
        myInit();
    }
    

    I was tried the connect method with argument Qt::BlockingQueuedConnection but i have obtain a deadlock !

    Have you an simple idea to "wait" the finish signal of a slot ? Of an another slot

    Thanks a lot

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      Have you an simple idea to "wait" the finish signal of a slot ?

      QEventLoop loop;
      QObject::connect(myobject,&MyObject::FinishedSignal,&loop,&QEventLoop::quit);
      loop.exec();
      

      "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

      E 1 Reply Last reply
      4
      • VRoninV VRonin

        Have you an simple idea to "wait" the finish signal of a slot ?

        QEventLoop loop;
        QObject::connect(myobject,&MyObject::FinishedSignal,&loop,&QEventLoop::quit);
        loop.exec();
        
        E Offline
        E Offline
        electro
        wrote on last edited by
        #3

        @VRonin Good idea, but how to do with two different thread ?

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

          Hi,

          Since you only have two threads why not just use a counter that you decrement when the slot is called and when at zero, execute the rest of your initialization ?

          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
          1
          • E Offline
            E Offline
            electro
            wrote on last edited by
            #5

            I have just put this argument in 5nd argument of connect method.

            Qt::BlockingQueuedConnection

            1 Reply Last reply
            0

            • Login

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