qt-interest@trolltech.com
[Top] [All Lists]

Re: [Qt 4.0] How to Use QTimer in a QThread?

Subject: Re: [Qt 4.0] How to Use QTimer in a QThread?
From: "Wu Yinghui, Freddie"
Date: Sat, 22 Apr 2006 09:48:48 +0800
Bradley T Hughes wrote:
> On Friday 21 April 2006 08:26, Wu Yinghui, Freddie wrote:
>> Bradley T Hughes wrote:
>> Thanks for your explanation, I get a better picture now.
>>
>> But let's say my main thread cannot run a Qt event loop (since I already
>> has an application with its own event loop), is there any way to make it
>> work besides the DirectConnection trick? (Note that my own slot is not
>> thread-safe, thus cannot be run in the main thread, but rather must be
>> run in the worker thread.)
> 
> At the end of your QThread subclass's constructor, you could move the thread 
> into itself:
> 
> Thread::Thread(...)
>     : QThread(...), ...
> {
>     ...
> 
>     moveToThread(this);
> }

Does this help? Since the constructor is running in the main thread...
Anyway, I'll test and report back.

Cheers,

Freddie

Attachment: yhwu.vcf
Description: Vcard

<Prev in Thread] Current Thread [Next in Thread>