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: Fri, 21 Apr 2006 09:37:17 +0800
Murphy, Sean M. wrote:
> I think it is working, but you've just set up a bad test.  From what you
> describe, it looks like the code is doing exactly what you are asking it
> to do.  You connect the timer's timeout to quit(), so the first time
> your timer fires, your app tries to quit, which in the process of
> quitting, tries to call your thread's destructor.  But in that
> destructor, you are calling wait() with no arguments.  Looking at the
> docs for QThread::wait():

Yes, I did read QThread::wait() before I posted the question. The quit()
slot is QThread::quit(), not the application's quit().

That's what I want to do in the test is to terminate the thread with a 1
second delay. The destructor will be called by the main() function when
the thread object is about to go out of scope. At this moment, I want to
wait for the thread termination (ideally, in about 1 second) before I
finally destruct the thread.

In fact, my initial test was to connect timeout() signal to my own slot
that does qDebug(). But nothing turned out on the console, which was why
I decided to use QThread's own slots for verification.

So, still, I cannot get the timer's timeout() signal to fire in all my
current tests...

Sorry if I didn't make the case clear enough earlier.

Cheers,

Freddie

-- 
Wu Yinghui, Freddie
Research & Development
Software Engineer

Volume Interactions Pte Ltd
1 Kim Seng Promenade, #12-01
Great World City East Tower
Singapore 237994
Tel:   +65 62226962 (Ext 216)
Fax:   +65 62226215
Email: yhwu@xxxxxxxxxxxxxxxxxxxxxx
URL:   http://www.volumeinteractions.com

Important:  This message is intended for the recipient(s) addressed
above.  It contains privileged and confidential information.  If you are
not the intended recipient, please notify the sender immediately by
replying to this message and then delete it from your system.  You must
not read, copy, use, or disseminate this communication in any form.
Thank you.

Attachment: yhwu.vcf
Description: Vcard

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