<?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[Not reading keyboard input after Pop-Up closes]]></title><description><![CDATA[<p dir="auto">Hey,<br />
I have an issue I can't seem to solve. In my application I create a pop-up window using QWidget. It shows up fine, accepts keyboard no problem. I connected a button. the reminder of the code doesn't really matter, saves data - that's all. But I want the button to close the pop-up, which also works 100% correctly. My issue is that when it closes, comes back to where the app were before the pop-up, I can't seem to be able to input anything to QLineEdits in the displayed window from the keyboard (that previously worked). I tried resetting them by using qLineEditName.setRealOnly(false); or even qLineEditName.setAcceptDrops(true);<br />
It's all in c++ obv.<br />
Honestly, no clue what I'm missing.</p>
<p dir="auto">P.S. I know making a global variable is a big no-no in regards to the esthetics of the code but hopefully it can be forgiven :)</p>
<pre><code>QWidget* popUpNewTime;
QTimeEdit* timeChoicePopUP;
QPushButton *button1;
void edit::on_addTime_clicked() {

    //Creating pop-up with time choice and a save button
    popUpNewTime = new QWidget(this, Qt::Popup);
    popUpNewTime-&gt;setWindowModality(Qt::WindowModal);
    QRect rect = QStyle::alignedRect(layoutDirection(), Qt::AlignBottom, QSize(width()/4, height()/6), geometry());
    popUpNewTime-&gt;setGeometry(rect);

    QVBoxLayout* layout = new QVBoxLayout(popUpNewTime);

    timeChoicePopUP = new QTimeEdit();
    button1 = new QPushButton("SAVE");

    layout-&gt;addWidget(timeChoicePopUP);
    layout-&gt;addWidget(button1);
    timeChoicePopUP-&gt;activateWindow();
    timeChoicePopUP-&gt;grabKeyboard();
    popUpNewTime-&gt;show();

    connect(button1,&amp;QPushButton::clicked,this, &amp;edit::addingTime);

}
void edit::addingTime() {
   timeChoicePopUP-&gt;close();
    button1-&gt;close();
    popUpNewTime-&gt;close();
}
</code></pre>
]]></description><link>https://forum.qt.io/topic/164935/not-reading-keyboard-input-after-pop-up-closes</link><generator>RSS for Node</generator><lastBuildDate>Sun, 27 Sep 2026 11:43:37 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/164935.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 26 Jul 2026 10:48:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Not reading keyboard input after Pop-Up closes on Sun, 26 Jul 2026 14:27:56 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">One thing that comes to mind: you never release the keyboard.<br />
Note that you are also leaking memory because closing a widget does not mean it gets deleted.<br />
By the way, it's not a question of esthetics, global variables are a bad idea most of the time but always in the case you are showing.</p>
]]></description><link>https://forum.qt.io/post/839389</link><guid isPermaLink="true">https://forum.qt.io/post/839389</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 26 Jul 2026 14:27:56 GMT</pubDate></item><item><title><![CDATA[Reply to Not reading keyboard input after Pop-Up closes on Sun, 26 Jul 2026 19:38:27 GMT]]></title><description><![CDATA[<p dir="auto">Well, first thing: do you really need to call grabKeyboard ? Why not just set the focus on the line edit ?</p>
]]></description><link>https://forum.qt.io/post/839399</link><guid isPermaLink="true">https://forum.qt.io/post/839399</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 26 Jul 2026 19:38:27 GMT</pubDate></item><item><title><![CDATA[Reply to Not reading keyboard input after Pop-Up closes on Sun, 26 Jul 2026 19:12:18 GMT]]></title><description><![CDATA[<p dir="auto">You could make that dialog a small class. It would make it self-contained and easier to use.</p>
]]></description><link>https://forum.qt.io/post/839393</link><guid isPermaLink="true">https://forum.qt.io/post/839393</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 26 Jul 2026 19:12:18 GMT</pubDate></item><item><title><![CDATA[Reply to Not reading keyboard input after Pop-Up closes on Sun, 26 Jul 2026 15:10:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> Thank you! it worked! Also, i fugured out how to do it without global variables. I didnt know how to use connect so i can declare the function within that call. From now on, no more global variables ;)</p>
]]></description><link>https://forum.qt.io/post/839390</link><guid isPermaLink="true">https://forum.qt.io/post/839390</guid><dc:creator><![CDATA[jakubd]]></dc:creator><pubDate>Sun, 26 Jul 2026 15:10:51 GMT</pubDate></item><item><title><![CDATA[Reply to Not reading keyboard input after Pop-Up closes on Sun, 26 Jul 2026 14:27:56 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">One thing that comes to mind: you never release the keyboard.<br />
Note that you are also leaking memory because closing a widget does not mean it gets deleted.<br />
By the way, it's not a question of esthetics, global variables are a bad idea most of the time but always in the case you are showing.</p>
]]></description><link>https://forum.qt.io/post/839389</link><guid isPermaLink="true">https://forum.qt.io/post/839389</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 26 Jul 2026 14:27:56 GMT</pubDate></item></channel></rss>