<?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[Problem with a modal dialog connecting with a process]]></title><description><![CDATA[<p dir="auto">Hi, everyone.</p>
<p dir="auto">I have created a dialog where a button's clicked method is connected with a slot to stop the process.<br />
When I clicked the cancel button, It seems the signal is emited once the process is finished, but I want to be able to cancel the operation in the middle of the process.</p>
<p dir="auto">It seems I have to run the process in a new thread, is it?<br />
Could I run the dialog in a new thread?</p>
<p dir="auto">Thank in advance.</p>
]]></description><link>https://forum.qt.io/topic/143394/problem-with-a-modal-dialog-connecting-with-a-process</link><generator>RSS for Node</generator><lastBuildDate>Tue, 23 Jun 2026 15:40:03 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/143394.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 03 Mar 2023 14:33:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem with a modal dialog connecting with a process on Fri, 03 Mar 2023 16:46:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/medihech">@<bdi>medihech</bdi></a> said in <a href="/post/749921">Problem with a modal dialog connecting with a process</a>:</p>
<blockquote>
<p dir="auto">. Is it possible?</p>
</blockquote>
<p dir="auto">Yes. See the <a href="https://doc.qt.io/qt-6/qprocess.html#running-a-process" target="_blank" rel="noopener noreferrer nofollow ugc">documentation</a> on how to start a process.</p>
]]></description><link>https://forum.qt.io/post/749931</link><guid isPermaLink="true">https://forum.qt.io/post/749931</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Fri, 03 Mar 2023 16:46:23 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with a modal dialog connecting with a process on Fri, 03 Mar 2023 16:36:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/medihech">@<bdi>medihech</bdi></a> said in <a href="/post/749926">Problem with a modal dialog connecting with a process</a>:</p>
<blockquote>
<p dir="auto">I need to cancel the process and continue it from the dialog several time because it is a long process.</p>
</blockquote>
<p dir="auto">Did you try <code>kill()</code>/<code>terminate()</code>?  Did you verify when your clicked slot is getting called as I mentioned a couple of times?  I don't know what there is not to understand, if you want to kill a process on a click then just do so.</p>
]]></description><link>https://forum.qt.io/post/749927</link><guid isPermaLink="true">https://forum.qt.io/post/749927</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Fri, 03 Mar 2023 16:36:23 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with a modal dialog connecting with a process on Fri, 03 Mar 2023 16:33:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a><br />
Thanks, but I dont understand completely.</p>
<p dir="auto">I need to cancel the process and continue it from the dialog several time because it is a long process.<br />
I could send a code it is necessary, but it did not work.</p>
]]></description><link>https://forum.qt.io/post/749926</link><guid isPermaLink="true">https://forum.qt.io/post/749926</guid><dc:creator><![CDATA[medihech]]></dc:creator><pubDate>Fri, 03 Mar 2023 16:33:39 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with a modal dialog connecting with a process on Fri, 03 Mar 2023 16:34:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/medihech">@<bdi>medihech</bdi></a><br />
In the <a href="https://doc.qt.io/qt-6/qprocess.html#public-slots" target="_blank" rel="noopener noreferrer nofollow ugc">slots section</a> of <code>QProcess</code> you have <code>kill()</code> and <code>terminate()</code>.  What else are you looking for?  And no need for any separate threads, won't help.</p>
<blockquote>
<p dir="auto">When I clicked the cancel button, It seems the signal is emited once the process is finished, but I want to be able to cancel the operation in the middle of the process.</p>
</blockquote>
<p dir="auto">Don't know what you're seeing.  What signal, that for the click?  Unless your computer is very busy running the other process so it doesn't service the request promptly.  Start with a <code>qDebug()</code> in your clicked handler so you know when it's called.</p>
<p dir="auto">Note that your <code>dialog-&gt;show()</code> means it's (presumably) a modeless dialog (oh, actually your title says you have set it modal).  You still have to allow the event loop to run.  Can't tell from your code, but if your <code>while (bExec)</code> blocks the event loop that might be a problem.  Like I said, start by verifying how promptly you get the clicked signal.</p>
<p dir="auto">Ah, hang on:</p>
<pre><code>cancel slot:
//update bool exec to false
</code></pre>
<p dir="auto">Just updating <code>bExec</code> to exit the <code>while</code> loop is not enough to kill the spawned process.  And I don't know what your <code>while (bExec)</code> is looping on if you have spawned a sub-process.</p>
]]></description><link>https://forum.qt.io/post/749924</link><guid isPermaLink="true">https://forum.qt.io/post/749924</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Fri, 03 Mar 2023 16:34:40 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with a modal dialog connecting with a process on Fri, 03 Mar 2023 16:09:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a></p>
<p dir="auto">Sorry, I did not explain it very well.<br />
The question I have is I want to run a process in background and at the same time, I should be able to stop it from a dialog . Is it possible?</p>
<p dir="auto">I do not have a code because I am not sure how to do it. I was thinking in use a thread. Could you give me some details to implement it?</p>
<p dir="auto">Thanks.</p>
]]></description><link>https://forum.qt.io/post/749921</link><guid isPermaLink="true">https://forum.qt.io/post/749921</guid><dc:creator><![CDATA[medihech]]></dc:creator><pubDate>Fri, 03 Mar 2023 16:09:36 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with a modal dialog connecting with a process on Fri, 03 Mar 2023 15:11:08 GMT]]></title><description><![CDATA[<p dir="auto">This is not even pseudo-code...<br />
How do you start the process, how do you try to stop it (or kill since stop can not work as there is no QProcess function for it).</p>
]]></description><link>https://forum.qt.io/post/749908</link><guid isPermaLink="true">https://forum.qt.io/post/749908</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Fri, 03 Mar 2023 15:11:08 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with a modal dialog connecting with a process on Fri, 03 Mar 2023 14:54:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a></p>
<p dir="auto">void Run(bool bExec)<br />
{</p>
<p dir="auto">while (bExec)<br />
{<br />
///Execute process<br />
}<br />
}</p>
<p dir="auto">main:<br />
//setup dialog<br />
//connect dialog button clicked to slot cancel<br />
dialog-&gt;show();</p>
<p dir="auto">cancel slot:<br />
//update bool exec to false</p>
<p dir="auto">user should be able to cancel the process by clicking the cancel button</p>
]]></description><link>https://forum.qt.io/post/749904</link><guid isPermaLink="true">https://forum.qt.io/post/749904</guid><dc:creator><![CDATA[medihech]]></dc:creator><pubDate>Fri, 03 Mar 2023 14:54:20 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with a modal dialog connecting with a process on Fri, 03 Mar 2023 14:40:26 GMT]]></title><description><![CDATA[<p dir="auto">Please provide a minimal, compilable example of your problem.<br />
How do you try to stop the process - I don't see a function in the <a href="https://doc.qt.io/qt-6/qprocess.html" target="_blank" rel="noopener noreferrer nofollow ugc">documenation</a>. There is just a function/slot to kill the process without any chance for the process to handle it somehow.</p>
]]></description><link>https://forum.qt.io/post/749901</link><guid isPermaLink="true">https://forum.qt.io/post/749901</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Fri, 03 Mar 2023 14:40:26 GMT</pubDate></item></channel></rss>