[Qt-interest] QThread run() method

anders.bakken at nokia.com anders.bakken at nokia.com
Sat Oct 3 00:14:17 CEST 2009


Exec is meant to block. If you do something like start a timer before  
calling exec you'll get timerevents delivered. Slots should also be  
invoked.

--

Anders

On Oct 2, 2009, at 1:08 PM, "ext Mike Jackson"  
<imikejackson at gmail.com> wrote:

> On 2009-09-16 09:10:10 -0400, Srdjan Todorovic
> <todorovic.s at googlemail.com> said:
>
>> Hi all,
>>
>> On 31/08/2009, Jeroen De Wachter <> wrote:
>>> One might suggest exiting the thread cleanly and just calling exit 
>>> () or
>>> quit() from within the thread instead of terminating it (while it  
>>> may
>>> hold a mutex, be in the middle of modifying data or anything else  
>>> of the
>>> sort)
>>
>> Quite some time ago (Qt 4.0/4.1) I created a QThread with its own
>> event loop. The idea was that, to quit the thread, some other object
>> would emit a signal to the thread with the event loop. This signal
>> would hit a slot in the thread that would do the cleanup of the  
>> thread
>> object and cause the event loop to exit. Once that happened, the run 
>> ()
>> method would finish and the thread would be done. One can then delete
>> it later on - I don't remember if I deleted it in a special way.
>>
>> Regards,
>> Srdjan
>
> Could you post exactly how you did this? I am having some problems
> sending signals from the main thread to a grand-child thread via
> Signals/Slots.
>
> My own thread class subclasses QThread and implements "void run();". I
> can not quite figure out how to get the even loop started. If I call
> "exec()" then that will block (or seems to in my code.
>
> Thanks
> MIke Jackson
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list