Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QStateMachine: How to add a condition for transitions?
I have a state machine that make transition, say T1, on leave event of a frame, that transition result in hiding of the frame. Now I added a QComboBox in the frame. But when I opens the box it the frame leave event invoked so frame disappeared and hence box too. Now I want to add condition that when transition one gonna happen state machine should check if enter event of combobox invoked or not. How to do this? Or There is a btter way to do this?
You just need to route the transition through a custom slot where you check your condition and emit a signal which triggers the state change.
So actually you decide when to switch to another state and thus you can check for an arbitrary condition.
can you please give a piece of code or any lick that explains concept.
taken from the "docs":http://qt-project.org/doc/qt-4.8/qstatemachine.html#details:
QState *s1 = new QState();
s1->assignProperty(&button, "text", "Click me");
QFinalState *s2 = new QFinalState();
s1->addTransition(&button, SIGNAL(clicked()), s2);
as you can see in the line:
...->addTransition(&button, SIGNAL(clicked()), s2);
You can decide when to advance to a new state/transition with a signal.
But it is not invoking slot. If I use a custom signal I have to emit it for which I have to invoke another slot again and that should be invoked by checking of enter event of qcombobox. complicated one, is it possible to check enter event of child widget at time of transition.