<?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[Deleting and recreating QApplication object]]></title><description><![CDATA[<p dir="auto">My application has command line interface when user can run different commands. Some commands can launch a GUI and once that GUI exits control come backs to command line interface. GUI can be launched and then closed any number of times.</p>
<p dir="auto">Currently during each GUI launch I create a new QApplication object and I delete it once GUI exits.<br />
Is this approach of deleting and recreating QApplication object safe?</p>
]]></description><link>https://forum.qt.io/topic/164624/deleting-and-recreating-qapplication-object</link><generator>RSS for Node</generator><lastBuildDate>Sat, 24 Oct 2026 02:55:00 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/164624.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 30 Apr 2026 13:47:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Deleting and recreating QApplication object on Mon, 04 May 2026 14:30:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kent-dorfman">@<bdi>Kent-Dorfman</bdi></a></p>
<blockquote>
<blockquote>
<p dir="auto">Moles and trolls...Moles and trolls...LOL</p>
</blockquote>
</blockquote>
<p dir="auto">Seen your own DP lately? Great Projection, so very helpful to newbies this is surely helping Qt stay afloat. Oh whats this? <a href="https://news.ycombinator.com/item?id=28627022" target="_blank" rel="noopener noreferrer nofollow ugc">https://news.ycombinator.com/item?id=28627022</a><br />
“Engineers can't explain it, legal can't understand it", “What companies want is certainty… Qt lacks it”,"It’s not just cost — it’s fear of getting licensing wrong",,"Qt's corporate owners have been openly hostile to the community for a while" are common sayings in the community? I was even being well civil but now i shall and will be otherwise:</p>
<p dir="auto">can't even answer lack of basic devops fundamental industry flows in QT, or improve itself while worse companies like microsoft can. May the likes of Oracle and Qt and others with majority investors from banking  sectors may drown in their yachts in random storms.. metaphorically.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a>  ban my soon to be autoscripted posts from my x many emails as x many times you want, truth will remain that Qt is abandonware without KDE and ugly frankenstein's monster with pinochio's nose thanks to yall bloodthirstynachtzikapitalists. You'r both getting traction at bilbili already. it will be fun :D Well i was able to rework my QT app to a better cross platform technology in just few hours and removed all Qt bs from my home now, also have I blocking my own account notifications coming from QT all ze bezt</p>
]]></description><link>https://forum.qt.io/post/838109</link><guid isPermaLink="true">https://forum.qt.io/post/838109</guid><dc:creator><![CDATA[GreatJobQTbeHostileToEvenNewbies]]></dc:creator><pubDate>Mon, 04 May 2026 14:30:43 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting and recreating QApplication object on Sat, 02 May 2026 14:04:38 GMT]]></title><description><![CDATA[<p dir="auto">Main command line interface application is pre existing older app and this GUI has been added much later. This relatively newly developed GUI interacts back and forth with the core application to send and receive data.</p>
<p dir="auto">Currently I am deleting and recreating QApplication object on GUI launch. I havn't faced any direct issue that points to this being a problem but there have been some other issues which might be completely unrelated to this or Qt code related to this GUI. But while exploring things I noticed this mentioned somewhere it is not a good idea to delete and recreate QApplication object so I just wanted to get the opinion here at the forum because I couldn't find anything explicitly mentioned in Qt documentation.</p>
]]></description><link>https://forum.qt.io/post/838082</link><guid isPermaLink="true">https://forum.qt.io/post/838082</guid><dc:creator><![CDATA[abhic]]></dc:creator><pubDate>Sat, 02 May 2026 14:04:38 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting and recreating QApplication object on Thu, 30 Apr 2026 21:59:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jeremy_k">@<bdi>jeremy_k</bdi></a> said in <a href="/post/838065">Deleting and recreating QApplication object</a>:</p>
<blockquote>
<p dir="auto">While a program can create and destroy the QCoreApplication instance multiple times*, cache objects, dynamically loaded libraries, etc may not be recreated from a clean initial state. <a href="https://doc.qt.io/qt-6/qlibrary.html#unload" target="_blank" rel="noopener noreferrer nofollow ugc">QLibrary::unload()</a> makes explicit mention of an inability to unload on macOS. Deleting and recreating might not accomplish what the OP is looking for.</p>
</blockquote>
<p dir="auto">OK.  I'll concede that this may cause problems, but as that being the case then I'd suggest that it's a "fault" that the Qt frameworks folks should address.  In my world, destroying QApplication should be a hard reset for the framework, and if it is not, then that makes me question the stability of the framework, but not enough to quit using it. LOL</p>
]]></description><link>https://forum.qt.io/post/838066</link><guid isPermaLink="true">https://forum.qt.io/post/838066</guid><dc:creator><![CDATA[Kent-Dorfman]]></dc:creator><pubDate>Thu, 30 Apr 2026 21:59:50 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting and recreating QApplication object on Thu, 30 Apr 2026 21:50:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kent-dorfman">@<bdi>Kent-Dorfman</bdi></a> said in <a href="/post/838060">Deleting and recreating QApplication object</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/abhic">@<bdi>abhic</bdi></a> said in <a href="/post/838059">Deleting and recreating QApplication object</a>:</p>
<blockquote>
<p dir="auto">Also can you share why I should avoid mixing command line and GUI in one app?</p>
</blockquote>
<p dir="auto">a) for the reason you mentioned above.  If Qt is leaking between instances of QApplication (it shouldn't be), then process isolation guarantees no leaks.</p>
</blockquote>
<p dir="auto">While a program can create and destroy the QCoreApplication instance multiple times*, cache objects, dynamically loaded libraries, etc may not be recreated from a clean initial state. <a href="https://doc.qt.io/qt-6/qlibrary.html#unload" target="_blank" rel="noopener noreferrer nofollow ugc">QLibrary::unload()</a> makes explicit mention of an inability to unload on macOS. Deleting and recreating might not accomplish what the OP is looking for.</p>
<p dir="auto">* - Some of the autotests rely on this ability. For example, <a href="https://code.qt.io/cgit/qt/qtbase.git/tree/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp#n106" target="_blank" rel="noopener noreferrer nofollow ugc">tst_QCoreApplication::qAppName()</a></p>
]]></description><link>https://forum.qt.io/post/838065</link><guid isPermaLink="true">https://forum.qt.io/post/838065</guid><dc:creator><![CDATA[jeremy_k]]></dc:creator><pubDate>Thu, 30 Apr 2026 21:50:23 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting and recreating QApplication object on Thu, 30 Apr 2026 20:20:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/abhic">@<bdi>abhic</bdi></a> said in <a href="/post/838059">Deleting and recreating QApplication object</a>:</p>
<blockquote>
<p dir="auto">Also can you share why I should avoid mixing command line and GUI in one app?</p>
</blockquote>
<p dir="auto">a) for the reason you mentioned above.  If Qt is leaking between instances of QApplication (it shouldn't be), then process isolation guarantees no leaks.<br />
b) modularization - I can often smell an application that is the product of incremental development with little to no pre-coding design analysis.  Your use-case has a scent of incremental development without sufficient pre-coding analysis.<br />
c) you have no guarantee that the GUI context can even be created from a command line application.  Different OS environment may or may not let you spawn GUIs from command line...what if you ssh/telnet in remotely?</p>
]]></description><link>https://forum.qt.io/post/838060</link><guid isPermaLink="true">https://forum.qt.io/post/838060</guid><dc:creator><![CDATA[Kent-Dorfman]]></dc:creator><pubDate>Thu, 30 Apr 2026 20:20:36 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting and recreating QApplication object on Thu, 30 Apr 2026 19:32:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kent-dorfman">@<bdi>Kent-Dorfman</bdi></a><br />
Thanks for your response. I have read at some place that Qt is not made for such usage where QApplication object is recreated after deletion. It recommended to reuse same QApplication object within an application, though I couldnt find any such reference in documentation. This is why I wanted to check here in this forum.</p>
<p dir="auto">Also can you share why I should avoid mixing command line and GUI in one app?</p>
]]></description><link>https://forum.qt.io/post/838059</link><guid isPermaLink="true">https://forum.qt.io/post/838059</guid><dc:creator><![CDATA[abhic]]></dc:creator><pubDate>Thu, 30 Apr 2026 19:32:45 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting and recreating QApplication object on Thu, 30 Apr 2026 15:35:29 GMT]]></title><description><![CDATA[<p dir="auto">It is probably the most safe way to do it.  I believe QApplication initializes Qt context for the framework, so starting with a fresh object in each instance is probably the "safer" way to go, but maybe not the most efficient.</p>
<p dir="auto">For myself, I would avoid mixing command line and GUI in one app but would put them into different processes and use IPC to communicate between them when necessary.</p>
]]></description><link>https://forum.qt.io/post/838058</link><guid isPermaLink="true">https://forum.qt.io/post/838058</guid><dc:creator><![CDATA[Kent-Dorfman]]></dc:creator><pubDate>Thu, 30 Apr 2026 15:35:29 GMT</pubDate></item></channel></rss>