Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QEventTransition doesn't work with QEvent::focusIn/Out
Forum Updated to NodeBB v4.3 + New Features

QEventTransition doesn't work with QEvent::focusIn/Out

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 194 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Donnie
    wrote on last edited by
    #1

    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 QEventTransition to QSignalTransition by replacing the events with some arbitrary QLineEdit signal - everything works.

    I tried subclassing QLineEdit and emitting custom signals on focus in/out events, but it seemed like it didn't help.

    What might be the cause?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved