<?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[VU Bargraph in QML - High consumption of CPU]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">I am writing an application with sixteen VU Bargrah like a VU in audio equipment, with C++ updating the state (turned on or off) of each element (LED) of each VU in QML. The refresh rate is 30 ms for each VU. Everything is working fine, but my application is consuming around 30% of the CPU (a Core 2 DUO - 2.8 GHz with Debian 6). I think I'm doing something wrong.</p>
<p dir="auto">This is a part of code of my VU in QML:</p>
<p dir="auto">@<br />
Column {<br />
spacing: intervalLeds</p>
<pre><code>  Repeater {
     model: numLeds

     Rectangle {
        id: vuLed
        objectName: "vuLed"
        width: widthLed
        height: heightLed
        border.width: 1
        color: "gray"
     }
  }
</code></pre>
<p dir="auto">}<br />
@</p>
<p dir="auto">Actually, I am changing the color property of each rectangle, with represent each LED of the VU bargraph, from gray to green.</p>
<p dir="auto">From C++, I am accessing each element of my VU in this way:</p>
<p dir="auto">@<br />
vuLeftLeds = vuLeft-&gt;findChildren&lt;QObject *&gt;("vuLed");<br />
@</p>
<p dir="auto">and changing the element color in this way:</p>
<p dir="auto">@<br />
<a href="http://vuLeftLeds.at" target="_blank" rel="noopener noreferrer nofollow ugc">vuLeftLeds.at</a>(i)-&gt;setProperty("color", "green");<br />
@</p>
<p dir="auto">I am using the raster graphics system. I trying with opengl, following a documentation from QML performance, but the CPU consumption in this way is greater the with raster, around 60%.</p>
<p dir="auto">Please, someone can help me with the problem of the CPU consumption or have a better idea to implement a VU bargraph in QML?</p>
<p dir="auto">Thank you very much!</p>
]]></description><link>https://forum.qt.io/topic/10945/vu-bargraph-in-qml-high-consumption-of-cpu</link><generator>RSS for Node</generator><lastBuildDate>Tue, 09 Jun 2026 05:20:28 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/10945.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 01 Nov 2011 22:44:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to VU Bargraph in QML - High consumption of CPU on Wed, 02 Nov 2011 18:08:43 GMT]]></title><description><![CDATA[<p dir="auto">Just out of curiosity, I tried this way:</p>
<p dir="auto">@<br />
Column {<br />
spacing: intervalLeds</p>
<pre><code>  Repeater {
     model: numLeds

     Image {
        id: vuLed
        objectName: "vuLed"
        width: widthLed
        height: heightLed
        source: ((valueRMS &lt;= index) || (valuePeak == index)) ? "./images/green_led.png" : "./images/gray_led.png"
     }         
  }
</code></pre>
<p dir="auto">}<br />
@</p>
<p dir="auto">but the performance was worse.</p>
<p dir="auto">Someone has a source code example of an application with the whole GUI with QML and opengl?</p>
]]></description><link>https://forum.qt.io/post/115404</link><guid isPermaLink="true">https://forum.qt.io/post/115404</guid><dc:creator><![CDATA[siécola]]></dc:creator><pubDate>Wed, 02 Nov 2011 18:08:43 GMT</pubDate></item><item><title><![CDATA[Reply to VU Bargraph in QML - High consumption of CPU on Wed, 02 Nov 2011 11:45:12 GMT]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">rcari, vuLeftLeds is a QList, and the findChildren method is called just once.</p>
<p dir="auto">This line:</p>
<p dir="auto">@<br />
<a href="http://vuLeftLeds.at" target="_blank" rel="noopener noreferrer nofollow ugc">vuLeftLeds.at</a>(i)-&gt;setProperty("color", "green");<br />
@</p>
<p dir="auto">is called every time that I need to update the VU value, but I did a lot of tests and this doesn't consume CPU time. If I set the same colors to the LEDs in VU every time, the CPU consumption is very low.</p>
<p dir="auto">Andre, thank you for suggestion. I tried, but the CPU consumption is the same with your solution (actually a lit bit more).</p>
<p dir="auto">Apparently, the CPU consumption is because the QML changing the colors of the LEDs of the VU. Is this normal?</p>
<p dir="auto">Can you imagine another way? Maybe changing the opacity of two bars, maybe changing a picture from gray to green.</p>
<p dir="auto">Why with opengl the CPU consumption is higher?</p>
<p dir="auto">Please, if someone has a solution, I would be grateful.</p>
<p dir="auto">Thanks!</p>
<p dir="auto">1-</p>
]]></description><link>https://forum.qt.io/post/115354</link><guid isPermaLink="true">https://forum.qt.io/post/115354</guid><dc:creator><![CDATA[siécola]]></dc:creator><pubDate>Wed, 02 Nov 2011 11:45:12 GMT</pubDate></item><item><title><![CDATA[Reply to VU Bargraph in QML - High consumption of CPU on Wed, 02 Nov 2011 10:45:32 GMT]]></title><description><![CDATA[<p dir="auto">I would try to leverage the declarative nature of QML a bit more. Why don't you just export a property to your QML with the value to respond to for each of the columns in your graph, and then set the colors using something like this:</p>
<p dir="auto">@<br />
Column {<br />
spacing: intervalLeds</p>
<p dir="auto">Repeater {<br />
model: numLeds</p>
<pre><code>  Rectangle {
     id: vuLed
     objectName: "vuLed"
     width: widthLed
     height: heightLed
     border.width: 1
     color: vuValues.column1Value &gt; maxValue/index ? "green" : "grey" 
  }
</code></pre>
<p dir="auto">}<br />
}<br />
@</p>
<p dir="auto">Now, all you need to do in C++ is to change the value of the column1Value property, and your items will color themselves without you iterating over them.</p>
<p dir="auto">Note that I did not test the code above.</p>
]]></description><link>https://forum.qt.io/post/115350</link><guid isPermaLink="true">https://forum.qt.io/post/115350</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Wed, 02 Nov 2011 10:45:32 GMT</pubDate></item><item><title><![CDATA[Reply to VU Bargraph in QML - High consumption of CPU on Wed, 02 Nov 2011 09:19:46 GMT]]></title><description><![CDATA[<p dir="auto">Well, using findChildren is all but optimal. Every time you call this method, your whole QObject tree is parsed to find all children that match this name. Every single object you have in the subtree is checked. Because of this, every time you want to update the screen you inspect your whole object tree causing heavy CPU consumption.<br />
You should create a specific data structure using a container like QVector to store pointers to the right objects or store/cache the list returned by the findChildren call. Then you can iterate quickly on this list of well-known objects, without having to find them each time.</p>
<p dir="auto">You can use valgrind to check where your program actually spends time but I am pretty sure your bottleneck will be in findChildren.</p>
]]></description><link>https://forum.qt.io/post/115339</link><guid isPermaLink="true">https://forum.qt.io/post/115339</guid><dc:creator><![CDATA[rcari]]></dc:creator><pubDate>Wed, 02 Nov 2011 09:19:46 GMT</pubDate></item></channel></rss>