[Top] [All Lists]

Re: OT - Need advice on pausing my program

Subject: Re: OT - Need advice on pausing my program
From: Chris Comparini
Date: Wed, 23 Nov 2005 11:20:43 -0800
On Wednesday 23 November 2005 11:02, you wrote:
> At this point I only have one thread - that is, I have not explicitly
> declared any threads.  The only one I'm using is the "main" thread - the
> thread that every program has.  I was wondering if I should use
> unistd.h's sleep function or if there was a Qt solution that worked on
> the main thread.

In that case the only problem with unistd's sleep is that it only lets
you specify whole seconds (not milliseconds).

However, in general, I would advise against blocking the main (GUI)
thread, since it can make your UI seem unresponsive to the user.

Come to think of it, if you just want to move things every 200ms,
a simple way might be to use a QTimer.  Basically, you could make
your method for moving stuff be a slot, and then just connect the
timerout() signal from a 200ms timer to it.  Then you wouldn't have
to deal with threads but your UI should remain smooth.

Oh, another thing - I seem to remember that there's something in
QCanvas for making sprites move "by themselves".. you can set 
velocities or something.  I've never used it though.

Hope that helps!

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