Results 1 to 2 of 2

Thread: Threading in Qt - Confusion

  1. #1
    Join Date
    Jan 2012
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Threading in Qt - Confusion

    Hi,

    I'm new to Qt and I am pretty confused by the way threading is done with Qt. If I look into the official docs, there is always the same way to create a thread. Create a subclass of QThread and implement your own run() function.

    Even new books about Qt 4 are telling this. It is pretty much the same, like in Java.

    Now I found this site.

    http://labs.qt.nokia.com/2010/06/17/...oing-it-wrong/

    and this

    http://mayaposch.wordpress.com/2011/...l-explanation/

    They are telling that subclassing QThread is wrong. Why do the official docs still listing the old "wrong" way?

    To create your own threads, subclass QThread and reimplement run().

    http://doc.trolltech.com/4.7/qthread.html
    And is it really wrong to subclass QThread? Do I have to use moveToThread()?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Threading in Qt - Confusion

    Quote Originally Posted by StarShaper View Post
    Why do the official docs still listing the old "wrong" way?
    I would tell you but I don't like using bad words in public.

    And is it really wrong to subclass QThread? Do I have to use moveToThread()?
    No, it's not inherently wrong but most of the time moveToThread() is better.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Threading with rsh and rcp
    By jaxrpc in forum Newbie
    Replies: 2
    Last Post: 4th June 2010, 11:50
  2. Threading...?
    By sekatsim in forum Qt Programming
    Replies: 12
    Last Post: 10th June 2008, 01:14
  3. Qt Threading
    By avh in forum Newbie
    Replies: 7
    Last Post: 30th May 2008, 20:20
  4. Multi threading ...
    By kiranraj in forum Qt Programming
    Replies: 2
    Last Post: 18th June 2007, 16:51
  5. Sub-Threading
    By TheGrimace in forum Qt Programming
    Replies: 4
    Last Post: 7th June 2007, 16:38

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.