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. How to move an object back to mainThread
Forum Updated to NodeBB v4.3 + New Features

How to move an object back to mainThread

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 578 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.
  • T Offline
    T Offline
    themts
    wrote on last edited by
    #1

    Hey guys,

    I have the following situation:
    I'm creating several objects in a separate thread via QtConcurrent.
    When I'm done, I need this object to live in the main thread.

    I tried "object->moveToThread(QApplication::instance()->thread());" but that doesn't work.

    What is the best way to achieve it?

    JKSHJ 1 Reply Last reply
    0
    • T themts

      Hey guys,

      I have the following situation:
      I'm creating several objects in a separate thread via QtConcurrent.
      When I'm done, I need this object to live in the main thread.

      I tried "object->moveToThread(QApplication::instance()->thread());" but that doesn't work.

      What is the best way to achieve it?

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

      @themts said in How to move an object back to mainThread:

      I tried "object->moveToThread(QApplication::instance()->thread());" but that doesn't work.

      See https://doc.qt.io/qt-5/qobject.html#moveToThread -- "this function can only "push" an object from the current thread to another thread, it cannot "pull" an object from any arbitrary thread to the current thread."

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

      1 Reply Last reply
      3
      • T Offline
        T Offline
        themts
        wrote on last edited by
        #3

        that is clear.
        I'm inside the QtConcurrent function and at the end I want to PUSH it to the mainThread.

        JKSHJ 1 Reply Last reply
        0
        • T themts

          that is clear.
          I'm inside the QtConcurrent function and at the end I want to PUSH it to the mainThread.

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

          @themts said in How to move an object back to mainThread:

          that is clear.
          I'm inside the QtConcurrent function and at the end I want to PUSH it to the mainThread.

          OK, that sounds good.

          Can you elaborate on what you mean by "that doesn't work"? What happens? How can you tell that it didn't work?

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

          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