[Qt-interest] Delay of code execution

Arnold Krille arnold at arnoldarts.de
Tue Apr 13 19:39:48 CEST 2010


On Tuesday 13 April 2010 17:52:31 Matthias Pospiech wrote:
> Andre Somers schrieb:
> > Perhaps you should talk about the issue you want to resolve by using a
> > delay, instead of the question on how to create a delay.
> I use delay in many cases:
> Here a few examples:
> (1)
>     piezoController->selectChannel(0);
>     piezoController->setPosition(center_pos);
>     delay(200);
> 
>     piezoController->selectChannel(1);
>     piezoController->setPosition(center_pos);
>     delay(200);
> 
>     piezoController->selectChannel(2);
>     piezoController->setPosition(center_pos);
>     delay(200);
<snip>

Sounds as if you want to sequence certain steps of actions.
I would create a table with the steps and the delays till the next execution-
step. And then set the values of the corresponding values and use 
QTimer::singleShot() to re-trigger the same function after the given interval.
That way it all stays responsive.
Or use a regular timer or timerEvent with the smallest allowed delay / 
sequencing step and do the stuff in there.

Making a thread wait is dangerous...

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100413/49ab668e/attachment.bin 


More information about the Qt-interest-old mailing list