QEventTransition doesn't work with QEvent::focusIn/Out
-
Here's a code snippet from the ctor of my custom widget
txt_ = new QLineEdit(this); lbl_ = new QLabel("Enter a message...", this); QVBoxLayout *vBoxLayout = new QVBoxLayout; vBoxLayout->addSpacing(lbl_->height()); vBoxLayout->addWidget(txt_); setLayout(vBoxLayout); QStateMachine *sm = new QStateMachine; QState *stateFocusedOut = new QState(sm); QRect rect1(250, 250, 100, 30); stateFocusedOut->assignProperty(lbl_, "geometry", rect1); sm->setInitialState(stateFocusedOut); QState *stateFocusedIn = new QState(sm); QRect rect2(0, 0, 100, 30); stateFocusedIn->assignProperty(lbl_, "geometry", rect2); QEventTransition *trans1 = new QEventTransition(txt_, QEvent::FocusIn, stateFocusedIn); stateFocusedOut->addTransition(trans1); QEventTransition *trans2 = new QEventTransition(txt_, QEvent::FocusOut, stateFocusedOut); stateFocusedIn->addTransition(trans2); QPropertyAnimation *anim1 = new QPropertyAnimation(lbl_, "geometry"); trans1->addAnimation(anim1); QPropertyAnimation *anim2 = new QPropertyAnimation(lbl_, "geometry"); trans2->addAnimation(anim2); sm->start();And the animations doesn't work when I use events for the state transitions. But if I change
QEventTransitiontoQSignalTransitionby replacing the events with some arbitraryQLineEditsignal - everything works.I tried subclassing
QLineEditand emitting custom signals on focus in/out events, but it seemed like it didn't help.What might be the cause?
-
Hi,
If memory serves well, QLineEdit should of have the focus policy to strong focus which should be what you need. Did you check that this is the case ?