Results 1 to 2 of 2

Thread: QThread: Move owner of thread to thread with moveToThread

  1. #1
    Join Date
    Dec 2011
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default QThread: Move owner of thread to thread with moveToThread

    Hi,
    is it ok to move the object owning the thread to the thread? Like in the example below.

    a.h:
    QThread* m_pThread;

    a.cpp:
    m_pThread = new QThread;
    this->moveToThread(m_pThread);

    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QThread: Move owner of thread to thread with moveToThread

    This probably can be done, but why do you need this construct?
    You probably have a design problem if you need this.
    Instead of this, check QRunnable.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. How can I get the thread ID out of QThread
    By Artschi in forum Qt Programming
    Replies: 9
    Last Post: 8th November 2017, 03:27
  2. multithread thread don't move
    By lzpmail in forum Qt Programming
    Replies: 11
    Last Post: 28th March 2011, 09:09
  3. Replies: 5
    Last Post: 22nd February 2011, 21:21
  4. Finishing a thread in QThread
    By Tio in forum Newbie
    Replies: 9
    Last Post: 2nd June 2010, 17:38
  5. GUI thread blocked using QThread.
    By summer_of_69 in forum Qt Programming
    Replies: 11
    Last Post: 18th May 2009, 09:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.