<?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[Threading and the main QT event loop.]]></title><description><![CDATA[<p dir="auto">I was hoping someone might give me some insight into how to better handle a situation I have. There are many time in this application where an event goes something like this:</p>
<ul>
<li>
<p dir="auto">User clicks button to do something</p>
</li>
<li>
<p dir="auto">Signal is sent to business logic to ask threaded application to do that thing</p>
</li>
<li>
<p dir="auto">Thing takes application x amount of time to do</p>
</li>
<li>
<p dir="auto">Application responds with thing</p>
</li>
</ul>
<p dir="auto">While x amount of time passes the main event thread is locked. Currently, the application deals with this scenario by creating a busy wait and while waiting calls the <code>QCoreApplication::processEvents();</code> which seems wrong. Can someone point me at some documentation for how other QT developers deal with situations like this? Perhaps they crafty use a mutex or simply ask the application to sleep? Perhaps a busy wait loop is the best option?</p>
]]></description><link>https://forum.qt.io/topic/141617/threading-and-the-main-qt-event-loop</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Apr 2026 09:31:55 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/141617.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 19 Dec 2022 19:19:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Threading and the main QT event loop. on Mon, 19 Dec 2022 20:06:22 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">What is your exact architecture ?</p>
<p dir="auto">If you have data exchange between two different applications you might want to consider using a model for the data and add a read-only entry to it while the creation is in progress with a status text explaining that. Then once the data is arrived make it read/write and show the actual data.</p>
<p dir="auto">There should be no need to freeze your UI for that. If you need to actually wait for something without your users being able to interact with your application then a QProgressDialog will be a better solution.</p>
]]></description><link>https://forum.qt.io/post/740831</link><guid isPermaLink="true">https://forum.qt.io/post/740831</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 19 Dec 2022 20:06:22 GMT</pubDate></item><item><title><![CDATA[Reply to Threading and the main QT event loop. on Mon, 19 Dec 2022 20:06:22 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">What is your exact architecture ?</p>
<p dir="auto">If you have data exchange between two different applications you might want to consider using a model for the data and add a read-only entry to it while the creation is in progress with a status text explaining that. Then once the data is arrived make it read/write and show the actual data.</p>
<p dir="auto">There should be no need to freeze your UI for that. If you need to actually wait for something without your users being able to interact with your application then a QProgressDialog will be a better solution.</p>
]]></description><link>https://forum.qt.io/post/740831</link><guid isPermaLink="true">https://forum.qt.io/post/740831</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 19 Dec 2022 20:06:22 GMT</pubDate></item><item><title><![CDATA[Reply to Threading and the main QT event loop. on Mon, 19 Dec 2022 19:56:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> Well, it depends on the instance but in general it's because the secondary application is the thing that is providing the real data that can be manipulated by the user. So for instance, let's say the user decides they want to create a job. The main application needs to ask the secondary application to first create the job (it handles remember the job exists) and then it feeds the primary application that job. So the user must wait for the job before they can start altering it or at least, that' s a simple way of handling it. Perhaps what should be done is to keep a copy of the job on the main application and then synchronize the data when it needs to be saved. Which may end up happening but in the meantime I was thinking perhaps the main application would be better served by a mutex or an atomic rather than using a busy wait loop to wait for the secondary application to finish processing.</p>
]]></description><link>https://forum.qt.io/post/740829</link><guid isPermaLink="true">https://forum.qt.io/post/740829</guid><dc:creator><![CDATA[RobM]]></dc:creator><pubDate>Mon, 19 Dec 2022 19:56:40 GMT</pubDate></item><item><title><![CDATA[Reply to Threading and the main QT event loop. on Mon, 19 Dec 2022 19:35:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/robm">@<bdi>RobM</bdi></a><br />
The <em>intention</em> of the Qt paradigm is that there ought be no "waiting".  Since your business logic runs in its own thread it just sends a signal when it is "done" or "has something to say".  I don't know why you busy wait + <code>processEvents()</code>.  Why does your UI have to "wait" for anything?</p>
]]></description><link>https://forum.qt.io/post/740819</link><guid isPermaLink="true">https://forum.qt.io/post/740819</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Mon, 19 Dec 2022 19:35:43 GMT</pubDate></item></channel></rss>