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. Two object calls for Qt child threads
Forum Updated to NodeBB v4.3 + New Features

Two object calls for Qt child threads

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 206 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.
  • N Offline
    N Offline
    Nan Feng
    wrote on last edited by Nan Feng
    #1

    Hi community coders. I have a question about using QThread. There is a thread object

    QThread* subThread = new QThread();
    

    l Then there are two normal objects.

    A* a = new A();  
    B* b = new B();
    

    Then

    a->moveToThread(subThread); 
    b->moveToThread(subThread);
    

    After completing the above steps, if the thread and the UI thread interact, you need to use the signal slot mechanism. So now that both a and b have moved to subThread thread, can a and b be called directly? For example, execute the b.say() method in a. In short, they all move to the same thread object through moveToThread, can they be called directly without signal slots?

    jsulmJ 1 Reply Last reply
    0
    • N Nan Feng

      Hi community coders. I have a question about using QThread. There is a thread object

      QThread* subThread = new QThread();
      

      l Then there are two normal objects.

      A* a = new A();  
      B* b = new B();
      

      Then

      a->moveToThread(subThread); 
      b->moveToThread(subThread);
      

      After completing the above steps, if the thread and the UI thread interact, you need to use the signal slot mechanism. So now that both a and b have moved to subThread thread, can a and b be called directly? For example, execute the b.say() method in a. In short, they all move to the same thread object through moveToThread, can they be called directly without signal slots?

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

      @Nan-Feng said in Two object calls for Qt child threads:

      can they be called directly without signal slots?

      yes

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

      N 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Nan-Feng said in Two object calls for Qt child threads:

        can they be called directly without signal slots?

        yes

        N Offline
        N Offline
        Nan Feng
        wrote on last edited by
        #3

        @jsulm Thank you very much for your reply! I wish you good health and all the best.

        1 Reply Last reply
        0
        • N Nan Feng has marked this topic as solved on
        • N Nan Feng has marked this topic as solved on

        • Login

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