<?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[this-&gt;close is not working correctly]]></title><description><![CDATA[<p dir="auto">Hey,<br />
I have a problem whereas I know this-&gt;close closes the current window<br />
I have created a another window in qt and I have to close the another window when user press a button but what happen is that it's close the current window as well as mainwindow and I only want to close the current one.<br />
Here is the piece of code</p>
<pre><code>  if(!exist(new_player,out_dup)){
out &lt;&lt; new_player;
file.flush();
file.close();
this-&gt;close();
</code></pre>
<p dir="auto">'Thanks in advance</p>
]]></description><link>https://forum.qt.io/topic/128116/this-close-is-not-working-correctly</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 18:41:29 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/128116.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 02 Jul 2021 07:25:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 14:27:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/pl45m4">@<bdi>Pl45m4</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> thanks a lot bro<br />
As I ask questions here I get a large variety which makes me much mature in qt<br />
Thanks from the bottom of my heart...</p>
]]></description><link>https://forum.qt.io/post/668585</link><guid isPermaLink="true">https://forum.qt.io/post/668585</guid><dc:creator><![CDATA[UG SEP]]></dc:creator><pubDate>Fri, 02 Jul 2021 14:27:34 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 13:34:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ug-sep">@<bdi>UG-SEP</bdi></a></p>
<p dir="auto">You dont need to "convert" anything. <code>QMainWindow</code> is just a regular <code>QWidget</code>, extended with <code>QToolBars</code> and other stuff.<br />
So you can pass a <code>parent</code> <code>QWidget</code> to the c'tor.</p>
<p dir="auto">For example you could create both widgets in your <code>main.cpp</code>, pass the parent with the MainWindow c'tor and show the Login form.</p>
<ul>
<li><a href="https://doc.qt.io/qt-5/qmainwindow.html#QMainWindow" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qmainwindow.html#QMainWindow</a></li>
</ul>
<p dir="auto">Edit:<br />
I'm assuming you what to do something like this, since your 2nd widget is called <code>Login</code>.:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/24520430/qt-login-dialog-box-before-main-window" target="_blank" rel="noopener noreferrer nofollow ugc">https://stackoverflow.com/questions/24520430/qt-login-dialog-box-before-main-window</a></li>
</ul>
<p dir="auto">There are so many examples out there...<br />
(If you do it like this, they both can be independent widgets. Then you dont even need a parent / child relation. It's all about a good design / structure.)</p>
]]></description><link>https://forum.qt.io/post/668580</link><guid isPermaLink="true">https://forum.qt.io/post/668580</guid><dc:creator><![CDATA[Pl45m4]]></dc:creator><pubDate>Fri, 02 Jul 2021 13:34:01 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 13:18:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a> ok as I will do it right now but can you tell me that how can I convert the base main window.CPP as child and Second Window as parent</p>
]]></description><link>https://forum.qt.io/post/668578</link><guid isPermaLink="true">https://forum.qt.io/post/668578</guid><dc:creator><![CDATA[UG SEP]]></dc:creator><pubDate>Fri, 02 Jul 2021 13:18:27 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 09:40:10 GMT]]></title><description><![CDATA[<p dir="auto">As it seems this second dialog is opened in the ctor of the first... strange idea. How should this work at all?<br />
Move it out of the ctor, check the return value and oen (or not) the mainwindow afterwards.</p>
]]></description><link>https://forum.qt.io/post/668535</link><guid isPermaLink="true">https://forum.qt.io/post/668535</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Fri, 02 Jul 2021 09:40:10 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 09:38:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ug-sep">@<bdi>UG-SEP</bdi></a></p>
<p dir="auto">Are your <code>this</code> window and the <code>other</code> window in a parent / child relation? If you close the parent, the child window may also get closed together with it.</p>
]]></description><link>https://forum.qt.io/post/668534</link><guid isPermaLink="true">https://forum.qt.io/post/668534</guid><dc:creator><![CDATA[Pl45m4]]></dc:creator><pubDate>Fri, 02 Jul 2021 09:38:37 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 08:35:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a></p>
<pre><code> ui-&gt;setupUi(this);
    QGuiApplication::setQuitOnLastWindowClosed(false);
    Login log;
    log.setModal(true);
    log.exec();
</code></pre>
<p dir="auto">I set it false but then also it the behaviour didn't changed</p>
]]></description><link>https://forum.qt.io/post/668516</link><guid isPermaLink="true">https://forum.qt.io/post/668516</guid><dc:creator><![CDATA[UG SEP]]></dc:creator><pubDate>Fri, 02 Jul 2021 08:35:24 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 08:20:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> said in <a href="/post/668511">this-&gt;close is not working correctly</a>:</p>
<blockquote>
<p dir="auto">How do you know? :-)</p>
</blockquote>
<p dir="auto">Since the default is true and I'm pretty sure it's not modified here.</p>
]]></description><link>https://forum.qt.io/post/668512</link><guid isPermaLink="true">https://forum.qt.io/post/668512</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Fri, 02 Jul 2021 08:20:47 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 08:17:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a> said in <a href="/post/668509">this-&gt;close is not working correctly</a>:</p>
<blockquote>
<p dir="auto">Yes since it was not set to false :)</p>
</blockquote>
<p dir="auto">How do you know? :-)</p>
]]></description><link>https://forum.qt.io/post/668511</link><guid isPermaLink="true">https://forum.qt.io/post/668511</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Fri, 02 Jul 2021 08:17:33 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 08:16:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> said in <a href="/post/668506">this-&gt;close is not working correctly</a>:</p>
<blockquote>
<p dir="auto">So, is this property set to true?</p>
</blockquote>
<p dir="auto">Yes since it was not set to false :)</p>
]]></description><link>https://forum.qt.io/post/668509</link><guid isPermaLink="true">https://forum.qt.io/post/668509</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Fri, 02 Jul 2021 08:16:02 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 08:15:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ug-sep">@<bdi>UG-SEP</bdi></a> Yes, see the link <a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a> posted, especially this part: "If this property is true, the applications quits when the last visible primary window". So, is this property set to true?</p>
]]></description><link>https://forum.qt.io/post/668506</link><guid isPermaLink="true">https://forum.qt.io/post/668506</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Fri, 02 Jul 2021 08:15:11 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 08:14:43 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">If you only have one top level widget visible and close it, then the application will stop. As <a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a> already pointed out, it's the normal behaviour.</p>
]]></description><link>https://forum.qt.io/post/668505</link><guid isPermaLink="true">https://forum.qt.io/post/668505</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Fri, 02 Jul 2021 08:14:43 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 08:12:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> It is closed because the <strong>Application Output</strong> give the output:</p>
<pre><code>13:41:39: E:\Qt in c++\Projects in Qt\build-BlackJack-Desktop_Qt_6_0_4_MinGW_64_bit-Debug\debug\BlackJack.exe exited with code 0

</code></pre>
]]></description><link>https://forum.qt.io/post/668503</link><guid isPermaLink="true">https://forum.qt.io/post/668503</guid><dc:creator><![CDATA[UG SEP]]></dc:creator><pubDate>Fri, 02 Jul 2021 08:12:43 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 08:09:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a> The main window was not closed, just hidden.</p>
]]></description><link>https://forum.qt.io/post/668501</link><guid isPermaLink="true">https://forum.qt.io/post/668501</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Fri, 02 Jul 2021 08:09:31 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 08:10:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> then also it closes both windows<br />
as well as I have checked whether after this-&gt;close run does the controller comes to main window or not by checking it using qDebug()&lt;&lt;</p>
]]></description><link>https://forum.qt.io/post/668500</link><guid isPermaLink="true">https://forum.qt.io/post/668500</guid><dc:creator><![CDATA[UG SEP]]></dc:creator><pubDate>Fri, 02 Jul 2021 08:10:13 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 08:06:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> said in <a href="/post/668497">this-&gt;close is not working correctly</a>:</p>
<blockquote>
<p dir="auto">How does it behave if you do not hide the main window?</p>
</blockquote>
<p dir="auto">The all works as expected:</p>
<p dir="auto"><a href="https://doc.qt.io/qt-5/qguiapplication.html#quitOnLastWindowClosed-prop" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qguiapplication.html#quitOnLastWindowClosed-prop</a></p>
]]></description><link>https://forum.qt.io/post/668499</link><guid isPermaLink="true">https://forum.qt.io/post/668499</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Fri, 02 Jul 2021 08:06:46 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 08:02:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ug-sep">@<bdi>UG-SEP</bdi></a> How does it behave if you do not hide the main window?</p>
]]></description><link>https://forum.qt.io/post/668497</link><guid isPermaLink="true">https://forum.qt.io/post/668497</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Fri, 02 Jul 2021 08:02:15 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 08:00:56 GMT]]></title><description><![CDATA[<p dir="auto">Here is the Main Window <a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a></p>
<pre><code>ui-&gt;setupUi(this);
    this-&gt;hide();
    Login log;
    log.setModal(true);
    log.exec();
    this-&gt;show();
</code></pre>
<p dir="auto">And well I did think that the program crashed because the <strong>application output</strong> show that the program exited with code(0) means runs successfully</p>
]]></description><link>https://forum.qt.io/post/668496</link><guid isPermaLink="true">https://forum.qt.io/post/668496</guid><dc:creator><![CDATA[UG SEP]]></dc:creator><pubDate>Fri, 02 Jul 2021 08:00:56 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 07:31:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ug-sep">@<bdi>UG-SEP</bdi></a> Then you will have to provide more information/code. How does the main window create the other window? Does it do anything when other window us closed?<br />
Also: is it possible that your app is simply crashing?</p>
]]></description><link>https://forum.qt.io/post/668491</link><guid isPermaLink="true">https://forum.qt.io/post/668491</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Fri, 02 Jul 2021 07:31:57 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 07:30:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> yes currently this is here the second window and when I close it the first one also closed</p>
]]></description><link>https://forum.qt.io/post/668490</link><guid isPermaLink="true">https://forum.qt.io/post/668490</guid><dc:creator><![CDATA[UG SEP]]></dc:creator><pubDate>Fri, 02 Jul 2021 07:30:51 GMT</pubDate></item><item><title><![CDATA[Reply to this-&gt;close is not working correctly on Fri, 02 Jul 2021 07:29:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ug-sep">@<bdi>UG-SEP</bdi></a> said in <a href="/post/668484">this-&gt;close is not working correctly</a>:</p>
<blockquote>
<p dir="auto">this-&gt;close();</p>
</blockquote>
<p dir="auto">So "this" is here the "other window", not main window?</p>
]]></description><link>https://forum.qt.io/post/668489</link><guid isPermaLink="true">https://forum.qt.io/post/668489</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Fri, 02 Jul 2021 07:29:43 GMT</pubDate></item></channel></rss>