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. Qthread and child thread communication between other thread
Forum Updated to NodeBB v4.3 + New Features

Qthread and child thread communication between other thread

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 6 Posters 2.1k 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.
  • R Offline
    R Offline
    RahibeMeryem
    wrote on last edited by
    #1

    Hi,

    I am creating threads in mainGUI thread with

        cam_01_thread = new QThread;
        cam_01 = new Camera01;
        cam_01->moveToThread(cam_01_thread);
    
        cam_02_thread = new QThread;
        cam_02 = new Camera_02;
        cam_02->moveToThread(cam_02_thread);
    
        frameProcess_thread = new QThread;
        process = new Camera_03;
        process->moveToThread(frameProcess_thread);
    

    all can ben communicate with mainGUI thats okey.

    I just wonder Can I use signal slot mechanism between these three threads ?

    such as cam1 and cam2 thread sends Region of isterest to the Process frame and process frame decide to whether send to mainGUI or not ?

    Or I can only communicate with the mainGui thread

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      You can use signals and slots between worker threads as well.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      4
      • R Offline
        R Offline
        RahibeMeryem
        wrote on last edited by RahibeMeryem
        #3

        @dheerendra
        All three thread created by mainGUI thread.

        So can we connect between these workers thread ?

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

          Hi,

          Yes you can connect objects belonging to different threads.

          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
          • R Offline
            R Offline
            RahibeMeryem
            wrote on last edited by
            #5

            @dheerendra
            @SGaist

            may I ask a simple example ?

            :)(:

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

              You have one in QThread's documentation.

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

              R 1 Reply Last reply
              3
              • SGaistS SGaist

                You have one in QThread's documentation.

                R Offline
                R Offline
                RahibeMeryem
                wrote on last edited by
                #7

                @SGaist

                I saw the example the thread created in the same class that going to be signal/slot used.

                Here the all three thread created in mainGUI inthat case how can I connect between these worker thread (signal/slot) or do I need to connectted only from mainGUI thread as broker ?

                I didnt see an example that same scenario as above?
                Best

                jsulmJ J.HilkJ 2 Replies Last reply
                0
                • R RahibeMeryem

                  @SGaist

                  I saw the example the thread created in the same class that going to be signal/slot used.

                  Here the all three thread created in mainGUI inthat case how can I connect between these worker thread (signal/slot) or do I need to connectted only from mainGUI thread as broker ?

                  I didnt see an example that same scenario as above?
                  Best

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

                  @RahibeMeryem

                  cam_01_thread = new QThread;
                      cam_01 = new Camera01;
                      cam_01->moveToThread(cam_01_thread);
                  
                      cam_02_thread = new QThread;
                      cam_02 = new Camera_02;
                      cam_02->moveToThread(cam_02_thread);
                  
                      frameProcess_thread = new QThread;
                      process = new Camera_03;
                      process->moveToThread(frameProcess_thread);
                  connect(cam_01, &Camera01::signal, cam_02, Camera_02::slot, Qt::QueuedConnection);
                  

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

                  1 Reply Last reply
                  3
                  • R RahibeMeryem

                    @SGaist

                    I saw the example the thread created in the same class that going to be signal/slot used.

                    Here the all three thread created in mainGUI inthat case how can I connect between these worker thread (signal/slot) or do I need to connectted only from mainGUI thread as broker ?

                    I didnt see an example that same scenario as above?
                    Best

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by J.Hilk
                    #9

                    @RahibeMeryem
                    nothing changes, really.

                    make your connect inside the main Thread - where you create the different threads & workes - because that class has acess the all your instances.

                    connect singal from worker 1 to slot of worker 2 and do the connect inside the main class/thread


                    jsulm was a bit faster ;-)

                    don't forget to subsditute signal and slot with actual signals&slots of your classes.


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    1 Reply Last reply
                    3
                    • VRoninV Offline
                      VRoninV Offline
                      VRonin
                      wrote on last edited by
                      #10
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        RahibeMeryem
                        wrote on last edited by
                        #11

                        cant believe so simple..

                        need to refresh my coffee.

                        thanks a lot all dear friends.

                        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