<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QEventTransition doesn&#x27;t work with QEvent::focusIn&#x2F;Out]]></title><description><![CDATA[<p dir="auto">Here's a code snippet from the ctor of my custom widget</p>
<pre><code>txt_ = new QLineEdit(this);
lbl_ = new QLabel("Enter a message...", this);

QVBoxLayout *vBoxLayout = new QVBoxLayout;
vBoxLayout-&gt;addSpacing(lbl_-&gt;height());
vBoxLayout-&gt;addWidget(txt_);
setLayout(vBoxLayout);

QStateMachine *sm = new QStateMachine;

QState *stateFocusedOut = new QState(sm);
QRect rect1(250, 250, 100, 30);
stateFocusedOut-&gt;assignProperty(lbl_, "geometry", rect1);
sm-&gt;setInitialState(stateFocusedOut);

QState *stateFocusedIn = new QState(sm);
QRect rect2(0, 0, 100, 30);
stateFocusedIn-&gt;assignProperty(lbl_, "geometry", rect2);

QEventTransition *trans1 = new QEventTransition(txt_, QEvent::FocusIn, stateFocusedIn);
stateFocusedOut-&gt;addTransition(trans1);

QEventTransition *trans2 = new QEventTransition(txt_, QEvent::FocusOut, stateFocusedOut);
stateFocusedIn-&gt;addTransition(trans2);

QPropertyAnimation *anim1 = new QPropertyAnimation(lbl_, "geometry");
trans1-&gt;addAnimation(anim1);

QPropertyAnimation *anim2 = new QPropertyAnimation(lbl_, "geometry");
trans2-&gt;addAnimation(anim2);

sm-&gt;start();
</code></pre>
<p dir="auto">And the animations doesn't work when I use events for the state transitions. But if I change <code>QEventTransition</code> to <code>QSignalTransition</code> by replacing the events with some arbitrary <code>QLineEdit</code> signal - everything works.</p>
<p dir="auto">I tried subclassing <code>QLineEdit</code> and emitting custom signals on focus in/out events, but it seemed like it didn't help.</p>
<p dir="auto">What might be the cause?</p>
]]></description><link>https://forum.qt.io/topic/136771/qeventtransition-doesn-t-work-with-qevent-focusin-out</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 20:35:08 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/136771.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 May 2022 22:59:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QEventTransition doesn&#x27;t work with QEvent::focusIn&#x2F;Out on Fri, 27 May 2022 19:34:51 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">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 ?</p>
]]></description><link>https://forum.qt.io/post/715589</link><guid isPermaLink="true">https://forum.qt.io/post/715589</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Fri, 27 May 2022 19:34:51 GMT</pubDate></item></channel></rss>