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. Send Var to Main thread
Qt 6.11 is out! See what's new in the release blog

Send Var to Main thread

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 934 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.
  • A Offline
    A Offline
    Alexanov
    wrote on last edited by
    #1

    Hi
    How can I send Variable or data from worker Thread (or other Thread implementation ) to Gui (Main Thread)?
    I do vice versa (Gui Thread to other thread ) with signal/slot.

    J.HilkJ jsulmJ 2 Replies Last reply
    0
    • A Alexanov

      Hi
      How can I send Variable or data from worker Thread (or other Thread implementation ) to Gui (Main Thread)?
      I do vice versa (Gui Thread to other thread ) with signal/slot.

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

      @Alexanov
      Thats exactly the way to do it:

      signals:
         void sendData(QVariant value);
      
      ...
      slots:
         void getData(QVariant value);
      
      
      //connect the 2
      
      connect(ObjectInThread1, &myThreadedClass1::sendData, ObjectInThread2, &mainThreadClass::getData, Qt::QueuedConnection);
      
      

      the with5th paramter is optional, but either leave it open aka Qt::AutoConnection or write Qt::QueuedConnection


      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
      2
      • A Alexanov

        Hi
        How can I send Variable or data from worker Thread (or other Thread implementation ) to Gui (Main Thread)?
        I do vice versa (Gui Thread to other thread ) with signal/slot.

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

        @Alexanov There is no difference whether from main thread to other thread or from other thread to main thread.

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

        1 Reply Last reply
        2

        • Login

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