<?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[Repeater and Delegate: ctx.fillStyle does not update color on DataChanged]]></title><description><![CDATA[<p dir="auto">Hallo,</p>
<p dir="auto">in my QML file I have the following Repeater. When I emit onDataChanged in my QAbstractListModel the coordinates of the circles are updated and the circles are drawn on the new place. But, I also change the colors of the circles in the model and these colors are not updated (<em>ctx.fillStyle = tcolor</em>). They stay in their initial value:<br />
(there are also other geometric objects, but that is not important for that)</p>
<pre><code>Repeater {
  id: partilcesreapeter
  model: Entrymodel
  delegate: chooser
  DelegateChooser{
    id: chooser
    role: "type"
    DelegateChoice{
      roleValue: "sphere";
      delegate: Item{
         id: sphereimage
         required property string tcolor
         required property int iparticle
         required property int semimajoraxis
         required property int semiminoraxis
         required property int xcoord
         required property int ycoord
         required property int angle
         width: 2.0*Number(semimajoraxis)
         height: 2.0*Number(semiminoraxis)
         x: Number(xcoord - semimajoraxis)
         y: Number(ycoord - semiminoraxis)
         Canvas {
            anchors.fill: parent                        
            onPaint: {
               var ctx = getContext('2d');
               ctx.beginPath();
               ctx.lineWidth = 1
               ctx.strokeStyle = "black"
               ctx.fillStyle = tcolor
               ctx.ellipse(x,y,width,height)
               ctx.stroke();
               ctx.fill();
               }
           }
           rotation: Number(angle)
           DelegateChoice{
              [...]
           }
        }
     }
  }
}
</code></pre>
<p dir="auto">So, what can I do?</p>
]]></description><link>https://forum.qt.io/topic/164712/repeater-and-delegate-ctx.fillstyle-does-not-update-color-on-datachanged</link><generator>RSS for Node</generator><lastBuildDate>Sun, 21 Jun 2026 04:55:59 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/164712.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 27 May 2026 19:25:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Repeater and Delegate: ctx.fillStyle does not update color on DataChanged on Fri, 29 May 2026 16:29:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/grecko">@<bdi>GrecKo</bdi></a> I also added some text to the circle.</p>
]]></description><link>https://forum.qt.io/post/838450</link><guid isPermaLink="true">https://forum.qt.io/post/838450</guid><dc:creator><![CDATA[Igor23]]></dc:creator><pubDate>Fri, 29 May 2026 16:29:45 GMT</pubDate></item><item><title><![CDATA[Reply to Repeater and Delegate: ctx.fillStyle does not update color on DataChanged on Thu, 28 May 2026 14:20:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/igor23">@<bdi>Igor23</bdi></a> said in <a href="/post/838418">Repeater and Delegate: ctx.fillStyle does not update color on DataChanged</a>:</p>
<blockquote>
<p dir="auto">I don't use Canvas directly, because there are different geometric objects [...]</p>
</blockquote>
<p dir="auto">My question was about the delegate inside the DelegatedChoice.</p>
<p dir="auto">Instead of <code>DelegateChoice { delegate: Item { Canvas {} }</code> you could do <code>DelegateChoice { delegate: Canvas {}}</code> if your Item doesn't hold more stuff.</p>
]]></description><link>https://forum.qt.io/post/838421</link><guid isPermaLink="true">https://forum.qt.io/post/838421</guid><dc:creator><![CDATA[GrecKo]]></dc:creator><pubDate>Thu, 28 May 2026 14:20:46 GMT</pubDate></item><item><title><![CDATA[Reply to Repeater and Delegate: ctx.fillStyle does not update color on DataChanged on Thu, 28 May 2026 13:36:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/grecko">@<bdi>GrecKo</bdi></a> Thanks a lot!<br />
in Canvas I wrote</p>
<pre><code>id: canvasSphere
</code></pre>
<p dir="auto">and before in <em>delegate: Item{</em></p>
<pre><code>onTcolorChanged: canvasSphere.requestPaint()
</code></pre>
<p dir="auto">Now the colors are updated.</p>
<p dir="auto">I don't use Canvas directly, because there are different geometric objects, which I choose by</p>
<pre><code>role: "type"
   DelegateChoice{
        roleValue: "sphere";
</code></pre>
<p dir="auto">Or is there a simplier way to do this?</p>
]]></description><link>https://forum.qt.io/post/838418</link><guid isPermaLink="true">https://forum.qt.io/post/838418</guid><dc:creator><![CDATA[Igor23]]></dc:creator><pubDate>Thu, 28 May 2026 13:36:11 GMT</pubDate></item><item><title><![CDATA[Reply to Repeater and Delegate: ctx.fillStyle does not update color on DataChanged on Thu, 28 May 2026 08:55:09 GMT]]></title><description><![CDATA[<p dir="auto">The Canvas is updated/repainter because its size changes but it doesn't know it should depend on <code>tcolor</code>.<br />
In your delegate, do <code>onTcolorChanged: canvas.requestPaint()</code>.</p>
<p dir="auto">It won't change much here but is there a reason for not directly using <code>Canvas</code> as your delegate here?</p>
]]></description><link>https://forum.qt.io/post/838411</link><guid isPermaLink="true">https://forum.qt.io/post/838411</guid><dc:creator><![CDATA[GrecKo]]></dc:creator><pubDate>Thu, 28 May 2026 08:55:09 GMT</pubDate></item></channel></rss>