<?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[Infinite condition checking]]></title><description><![CDATA[<p dir="auto">I have a task  where a function is called and the first thing done in that is to call a <code>bool</code> function to check a condition before proceeding. If that condition is true the code proceeds and if not it returns.</p>
<p dir="auto">But I need a way to periodically check that condition, if it ever returns that function will be called again.</p>
<pre><code>bool condition()
{
...
    //return true or false;
}

void foo()
{
    if( ! condition)
        return;

...

}

</code></pre>
<p dir="auto">I need to find a way to go back to <code>foo</code> in case <code>condition</code> ever returns true.</p>
<p dir="auto">I  thought about  <code>QEventLoop</code> but I want more options.</p>
<p dir="auto">Any help is appreciated. Thanks in advance!</p>
]]></description><link>https://forum.qt.io/topic/123984/infinite-condition-checking</link><generator>RSS for Node</generator><lastBuildDate>Fri, 06 Nov 2026 12:13:14 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/123984.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 19 Feb 2021 15:03:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Infinite condition checking on Tue, 23 Feb 2021 21:30:02 GMT]]></title><description><![CDATA[<p dir="auto">Order of destruction, code run during destruction, etc</p>
<p dir="auto">Think of a database, you likely appreciate the fact that all operations are finalised before it stops so you don't have corrupted data when you restart it.</p>
]]></description><link>https://forum.qt.io/post/646029</link><guid isPermaLink="true">https://forum.qt.io/post/646029</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 23 Feb 2021 21:30:02 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Mon, 22 Feb 2021 22:50:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a>  <a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a></p>
<blockquote>
<p dir="auto">Ending an application does not mean everything is destroyed instantly.</p>
</blockquote>
<p dir="auto">I have followed your suggestion, and now I am wondering, is this something that I have to always watch out for, is there a name for this kind of situation, a reference I can search?</p>
<p dir="auto">And also, why is everything  not destroyed instantly? What are the steps being taken? What is happening under the hood there? Any reference?</p>
]]></description><link>https://forum.qt.io/post/645802</link><guid isPermaLink="true">https://forum.qt.io/post/645802</guid><dc:creator><![CDATA[hbatalha]]></dc:creator><pubDate>Mon, 22 Feb 2021 22:50:19 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Mon, 22 Feb 2021 12:47:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> ok thanks</p>
]]></description><link>https://forum.qt.io/post/645731</link><guid isPermaLink="true">https://forum.qt.io/post/645731</guid><dc:creator><![CDATA[hbatalha]]></dc:creator><pubDate>Mon, 22 Feb 2021 12:47:03 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Mon, 22 Feb 2021 06:15:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hbatalha">@<bdi>hbatalha</bdi></a> said in <a href="/post/645667">Infinite condition checking</a>:</p>
<blockquote>
<p dir="auto">is part of another class</p>
</blockquote>
<p dir="auto">Then put it there as member variable and stop it in destructor (or whenever needed).</p>
]]></description><link>https://forum.qt.io/post/645669</link><guid isPermaLink="true">https://forum.qt.io/post/645669</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Mon, 22 Feb 2021 06:15:19 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Mon, 22 Feb 2021 06:11:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> foo is not from the mainwindow, is part of another class, should I call stop in the destructor?</p>
]]></description><link>https://forum.qt.io/post/645667</link><guid isPermaLink="true">https://forum.qt.io/post/645667</guid><dc:creator><![CDATA[hbatalha]]></dc:creator><pubDate>Mon, 22 Feb 2021 06:11:19 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Sat, 20 Feb 2021 20:19:59 GMT]]></title><description><![CDATA[<p dir="auto">I don't know how long foo will take so you might not want for it to triggered when you end your application. Ending an application does not mean everything is destroyed instantly.</p>
]]></description><link>https://forum.qt.io/post/645582</link><guid isPermaLink="true">https://forum.qt.io/post/645582</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sat, 20 Feb 2021 20:19:59 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Sat, 20 Feb 2021 20:15:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> didn't quite understand what you meant, when my application won't everything be stopped?</p>
<p dir="auto">Also, I need to call foo only once when the timeout is emitted, took that example from the documentation.</p>
]]></description><link>https://forum.qt.io/post/645581</link><guid isPermaLink="true">https://forum.qt.io/post/645581</guid><dc:creator><![CDATA[hbatalha]]></dc:creator><pubDate>Sat, 20 Feb 2021 20:15:37 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Sat, 20 Feb 2021 20:00:14 GMT]]></title><description><![CDATA[<p dir="auto">You might want to consider making a QTimer member variable to be able to stop it for example when your application ends.</p>
]]></description><link>https://forum.qt.io/post/645573</link><guid isPermaLink="true">https://forum.qt.io/post/645573</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sat, 20 Feb 2021 20:00:14 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Sat, 20 Feb 2021 02:58:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> That did solve my problem, thanks</p>
<pre><code>void SomeClass::foo()
{
    if( ! condition)
    {
        QTimer::singleShot(5000, this, &amp;SomeClass::foo);

        return;
    }
...

}
</code></pre>
]]></description><link>https://forum.qt.io/post/645532</link><guid isPermaLink="true">https://forum.qt.io/post/645532</guid><dc:creator><![CDATA[hbatalha]]></dc:creator><pubDate>Sat, 20 Feb 2021 02:58:11 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Fri, 19 Feb 2021 21:00:08 GMT]]></title><description><![CDATA[<p dir="auto">Sounds like a simple <a href="https://doc.qt.io/qt-5/qtimer.html" target="_blank" rel="noopener noreferrer nofollow ugc">QTimer</a> that calls foo regularly should do the job.</p>
]]></description><link>https://forum.qt.io/post/645516</link><guid isPermaLink="true">https://forum.qt.io/post/645516</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Fri, 19 Feb 2021 21:00:08 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Fri, 19 Feb 2021 20:39:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> something that calls condition regularly and if condition returns true then foo will be called</p>
]]></description><link>https://forum.qt.io/post/645511</link><guid isPermaLink="true">https://forum.qt.io/post/645511</guid><dc:creator><![CDATA[hbatalha]]></dc:creator><pubDate>Fri, 19 Feb 2021 20:39:14 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Fri, 19 Feb 2021 19:16:57 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Since foo checks the condition on each call, in fact, you want something that calls regularly foo ?</p>
]]></description><link>https://forum.qt.io/post/645487</link><guid isPermaLink="true">https://forum.qt.io/post/645487</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Fri, 19 Feb 2021 19:16:57 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Fri, 19 Feb 2021 17:55:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/raven-worx">@<bdi>raven-worx</bdi></a> I am not using QML</p>
<blockquote>
<p dir="auto">but the extra logic is needed</p>
</blockquote>
<p dir="auto">Is there another way to do this?</p>
]]></description><link>https://forum.qt.io/post/645480</link><guid isPermaLink="true">https://forum.qt.io/post/645480</guid><dc:creator><![CDATA[hbatalha]]></dc:creator><pubDate>Fri, 19 Feb 2021 17:55:55 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Fri, 19 Feb 2021 15:32:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hbatalha">@<bdi>hbatalha</bdi></a><br />
but the extra logic is needed, since you want to block the execution but actually you do not want to.<br />
You can use <a href="https://doc.qt.io/qt-5.12/qml-workerscript.html" target="_blank" rel="noopener noreferrer nofollow ugc">WorkerScripts in QML</a> which act like threads.</p>
]]></description><link>https://forum.qt.io/post/645459</link><guid isPermaLink="true">https://forum.qt.io/post/645459</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Fri, 19 Feb 2021 15:32:47 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Fri, 19 Feb 2021 15:28:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/raven-worx">@<bdi>raven-worx</bdi></a> I thought about creating a loop that would run indefinitely until the condition returns true, if it ever does, meanwhile the user can use the application "normally".<br />
But I don't want to use <code>QEventLoop </code>, because it adds an extra complexity to the program. That's why I want more options.</p>
]]></description><link>https://forum.qt.io/post/645457</link><guid isPermaLink="true">https://forum.qt.io/post/645457</guid><dc:creator><![CDATA[hbatalha]]></dc:creator><pubDate>Fri, 19 Feb 2021 15:28:27 GMT</pubDate></item><item><title><![CDATA[Reply to Infinite condition checking on Fri, 19 Feb 2021 15:23:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hbatalha">@<bdi>hbatalha</bdi></a> said in <a href="/post/645447">Infinite condition checking</a>:</p>
<blockquote>
<p dir="auto">I  thought about  QEventLoop but I want more options.</p>
</blockquote>
<p dir="auto">elaborate</p>
]]></description><link>https://forum.qt.io/post/645454</link><guid isPermaLink="true">https://forum.qt.io/post/645454</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Fri, 19 Feb 2021 15:23:06 GMT</pubDate></item></channel></rss>