[Qt-interest] QThread event loop running in main thread?

Mihail Naydenov mlists at ymail.com
Mon Dec 27 20:43:15 CET 2010


Just to point out subclassing and impl. run() is not the wrong way, it is the 
old way.

The  wrong way is subclassing qthread and *not* impl. run(), but moving it with 
moveToThread(this) and doing work in its slots.


(having said that its is not *wrong* by definition, it is ... weird and 
confusing, still Qt itself uses it in  (IIRC) QFileSystemWatcher )

MihailNaydenov


----- Original Message ----
> From: Bob Hood <bhood2 at comcast.net>
> To: qt-interest at qt.nokia.com
> Sent: Mon, December 27, 2010 8:40:30 PM
> Subject: Re: [Qt-interest] QThread event loop running in main thread?
> 
> On 12/27/2010 11:22 AM, Andre Somers wrote:
> > Op 27-12-2010 18:21, Bob  Hood schreef:
> >> On 12/27/2010 9:51 AM, BRM wrote:
> >>> Two  very different models, but neither have any good examples in the  Qt
> >>> documentation. That said, I have come across several very  good blog posts 
>on
> >>> Qt Labs per QThreading - one of which is what  converted me to start using
> >>> the second model above (no QThread  derivatives), though I can't seem to 
>find
> >>> it right  now.
> >> Would this be it?
> >>
> >>  http://labs.qt.nokia.com/2010/06/17/youre-doing-it-wrong/
> > Probably. And  if you read through the comments, the complaint most heard 
> > is: "this is  not properly documented, please fix that", along with 
> > remarks that the  "wrong" way is actually suggested in the docs...
> >
> > I have used  several ways that I all managed to get to work, but I think 
> > that for  general usage, the create-QObject-and-move-to-QThread way is 
> > the  easiest to work with.
> 
> I don't know.  I have a stand-alone  application written using Qt 4.6.x that
> performs branch management with  Subversion.  It supports unlimited numbers of
> root and child branches,  where each could have a thread running at any given
> time.  It uses the  "wrong" way of threading (i.e., sub-classing QThread and
> re-implementing  run()) and everything works just fine.  I've had no issues at
> all with  this approach.
> 
> I implemented this way before I found that article, but  see no real reason to
> re-factor into compliance with the "right" way as I  ain't gonna fix what 
ain't
> broken.   ;)
> 
> _______________________________________________
> Qt-interest mailing  list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
> 


      



More information about the Qt-interest-old mailing list