I'm having a problem on transitioning between states, by hovering on the object.
I have tried this code
QStateMachine machine;
machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
QState *group = new QState(&machine);
group->setObjectName("group");
QRect selectedRect
(270,
125,
130,
130);
QState *idleState = new QState(group);
group->setInitialState(idleState);
QObjectList objects;
objects << p1 << p2 << p3;
QState *state1 = new QState(group);
QState *state2 = new QState(group);
QState *state3 = new QState(group);
state1->assignProperty(p1, "geometry", selectedRect);
state2->assignProperty(p2, "geometry", selectedRect);
state3->assignProperty(p3, "geometry", selectedRect);
// Enter P1
QEventTransition
*enterTransition
= new QEventTransition
(p1,
QEvent::Enter);
enterTransition->setTargetState(state1);
group->addTransition(enterTransition);
// Enter P2
QEventTransition
*enterTransition
= new QEventTransition
(p2,
QEvent::Enter);
enterTransition->setTargetState(state2);
group->addTransition(enterTransition);
// Enter P2
QEventTransition
*enterTransition
= new QEventTransition
(p3,
QEvent::Enter);
enterTransition->setTargetState(state3);
group->addTransition(enterTransition);
window.createAnimations(objects, &machine);
machine.addState(s1);
machine.addState(s2);
machine.addState(s3);
machine.setInitialState(group);
machine.start();
QStateMachine machine;
machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
QState *group = new QState(&machine);
group->setObjectName("group");
QRect selectedRect(270, 125, 130, 130);
QState *idleState = new QState(group);
group->setInitialState(idleState);
QObjectList objects;
objects << p1 << p2 << p3;
QState *state1 = new QState(group);
QState *state2 = new QState(group);
QState *state3 = new QState(group);
state1->assignProperty(p1, "geometry", selectedRect);
state2->assignProperty(p2, "geometry", selectedRect);
state3->assignProperty(p3, "geometry", selectedRect);
// Enter P1
QEventTransition *enterTransition = new QEventTransition(p1, QEvent::Enter);
enterTransition->setTargetState(state1);
group->addTransition(enterTransition);
// Enter P2
QEventTransition *enterTransition = new QEventTransition(p2, QEvent::Enter);
enterTransition->setTargetState(state2);
group->addTransition(enterTransition);
// Enter P2
QEventTransition *enterTransition = new QEventTransition(p3, QEvent::Enter);
enterTransition->setTargetState(state3);
group->addTransition(enterTransition);
window.createAnimations(objects, &machine);
machine.addState(s1);
machine.addState(s2);
machine.addState(s3);
machine.setInitialState(group);
machine.start();
To copy to clipboard, switch view to plain text mode
It works fine if I try to trigger the transition with a mouse click,
group->addTransition(p1, SIGNAL(clicked()), state1);
group->addTransition(p1, SIGNAL(clicked()), state1);
To copy to clipboard, switch view to plain text mode
So I think I'm doing something wrong with the QEventTransition,
but I have no idea what I'm doing wrong.
Thanks.
Bookmarks