PDA

View Full Version : Perform a cyclic task in a QState



schall_l
16th April 2010, 15:45
Hi,

I would like to know if there is a possibility to perform a cyclic task in a QState, or if it is not advised to so such a thing.
In my case I would like to detect the presence of a device connected to my PC before using it.
So I was thinking using a QStateMachine with something like:

QState *s1_detectDriver = new QState();
QState *s2_detectDevice = new QState();
QState *s3_connectToDevice = new QState();

In my state s2_detectDevice I would like to use the driver to find out if the device is connected. If not I have to ask again after a certain time, if not I have to ask again after a certain time and so on... once the device is connected I can connect to it.

Does it make sense to use QStateMachine for such kind of thing ?

wysota
16th April 2010, 23:18
I would consider using a state machine in such situation as an overkill. Unless it's part of some bigger process (like changing properties of some objects upon state changes, etc.).