<?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[QTimer restart increasing CPU usage]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I need to reset a QTimer every time the touchscreen of a display is pressed. I'm using this command to reset the timer:</p>
<pre><code>timer-&gt;start(interval*1000*60);
</code></pre>
<p dir="auto">But every time I touch the display the CPU usage of the programa increases. Does anybody know how to correct it? After some time using the program, the CPU usage gets 100%;</p>
<p dir="auto">Any tip will be very helpful,<br />
Thanks.</p>
]]></description><link>https://forum.qt.io/topic/63098/qtimer-restart-increasing-cpu-usage</link><generator>RSS for Node</generator><lastBuildDate>Mon, 20 Apr 2026 19:49:05 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/63098.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 21 Jan 2016 17:16:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QTimer restart increasing CPU usage on Fri, 22 Jan 2016 10:47:52 GMT]]></title><description><![CDATA[<p dir="auto">What is your OS and your version of Qt?</p>
<p dir="auto">What are the usual values of <code>interval</code>?</p>
]]></description><link>https://forum.qt.io/post/308880</link><guid isPermaLink="true">https://forum.qt.io/post/308880</guid><dc:creator><![CDATA[JKSH]]></dc:creator><pubDate>Fri, 22 Jan 2016 10:47:52 GMT</pubDate></item><item><title><![CDATA[Reply to QTimer restart increasing CPU usage on Fri, 22 Jan 2016 10:34:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a></p>
<p dir="auto">Thanks for your answer!</p>
<p dir="auto">I commented all the content of the function that is called when timeout happens (turnOnDisplay). However, the CPU usage increasing still continues. The only line that is beeing called is</p>
<pre><code>timer-&gt;start(interval*1000*60);

</code></pre>
]]></description><link>https://forum.qt.io/post/308871</link><guid isPermaLink="true">https://forum.qt.io/post/308871</guid><dc:creator><![CDATA[marcosbontempo]]></dc:creator><pubDate>Fri, 22 Jan 2016 10:34:03 GMT</pubDate></item><item><title><![CDATA[Reply to QTimer restart increasing CPU usage on Thu, 21 Jan 2016 19:55:29 GMT]]></title><description><![CDATA[<p dir="auto">hmm.<br />
It dont really look heavy.<br />
I wonder if qdbc-&gt;photoframe-&gt;runPhotoframe();<br />
could be the heavy one?</p>
]]></description><link>https://forum.qt.io/post/308724</link><guid isPermaLink="true">https://forum.qt.io/post/308724</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Thu, 21 Jan 2016 19:55:29 GMT</pubDate></item><item><title><![CDATA[Reply to QTimer restart increasing CPU usage on Thu, 21 Jan 2016 18:33:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a></p>
<p dir="auto">I use the same timer.</p>
<p dir="auto">I don't have loops in the function that is called when timeout happens.</p>
<p dir="auto">When I press the touchscreen, this function is executed:</p>
<pre><code>void TimeControl::restartTimeCounter(int timeoutType)
{
    // Restart timer:
    int interval = qdbc-&gt;generalconfig-&gt;getConfigurationInt(CONFIGURATION_ATTRIBUTE_DISPLAY_IDLE_TIME);
    timer-&gt;stop();
    timer-&gt;start(interval*1000*60); // LINHA QUE CAUSA O AUMENTO DE CPU

    switch(timeoutType)
    {
        case 1: // Display control
            if(display == false)
            {
                display = true;
                turnOnDisplay();
            }
        break;
    }
}
</code></pre>
<p dir="auto">This is the  function that is called when timeout happens:</p>
<pre><code>void TimeControl::turnOnDisplay()
{
    QFile backlight_file(backlight);

    int action = qdbc-&gt;generalconfig-&gt;getConfigurationInt(CONFIGURATION_ATTRIBUTE_DISPLAY_ACTION);

    if(display)
    {
        switch(action)
        {
            case PhotoFrame:
                // Stop photoframe
                qdbc-&gt;photoframe-&gt;stopPhotoframe();
            break;
            case Brightness:
                // Turn on display
                QString brightness = qdbc-&gt;generalconfig-&gt;getConfigurationString(CONFIGURATION_ATTRIBUTE_DISPLAY_BRIGHTNESS);
                if(backlight_file.open(QFile::WriteOnly | QFile::Truncate)){
                    backlight_file.reset();
                    QTextStream back(&amp;backlight_file);
                    back &lt;&lt; brightness;
                }
                backlight_file.close();
            break;
        }

        display = true;
    }
    else
    {
        switch(action)
        {
            case PhotoFrame:
                // Run Photoframe
                qdbc-&gt;photoframe-&gt;runPhotoframe();
            break;
            case Brightness:
                // Turn off display
                if(backlight_file.open(QFile::WriteOnly | QFile::Truncate)){
                    backlight_file.reset();
                    QTextStream back(&amp;backlight_file);
                    back &lt;&lt; "0";
                    qdbc-&gt;callreceived-&gt;closeGUI();
                }
                backlight_file.close();
            break;
            case MainPage:
                // Return to main page
                qdbc-&gt;callreceived-&gt;closeGUI();
            break;
        }

        display = false;
    }
}
</code></pre>
]]></description><link>https://forum.qt.io/post/308715</link><guid isPermaLink="true">https://forum.qt.io/post/308715</guid><dc:creator><![CDATA[marcosbontempo]]></dc:creator><pubDate>Thu, 21 Jan 2016 18:33:18 GMT</pubDate></item><item><title><![CDATA[Reply to QTimer restart increasing CPU usage on Thu, 21 Jan 2016 17:45:16 GMT]]></title><description><![CDATA[<p dir="auto">hi<br />
from one line of code its hard to give guesses.</p>
<p dir="auto">Do you create a new timer each time you "touch" ?</p>
<p dir="auto">The function that is called when timeout happens, what are you doing in there?`<br />
Do you have loops ?</p>
]]></description><link>https://forum.qt.io/post/308711</link><guid isPermaLink="true">https://forum.qt.io/post/308711</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Thu, 21 Jan 2016 17:45:16 GMT</pubDate></item></channel></rss>