<?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[Forcing QGraphicsWidget::setGeometry to execute....?]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">I'm trying to figure out how to force <code>QGraphicsWidget::setGeometry</code> to fully execute - even when I'm passing in a geometry that is exactly the same as the current geometry for that widget.</p>
<p dir="auto">In my code I have a section that calls <code>QGraphicsWidget::resize(width, height);</code><br />
Which then internally calls <code>QGraphicsWidget::setGeometry(width, height)</code><br />
Sometimes users come across a corner case where large parts of the GUI has changed and been redrawn, but this specific part has the same geometry, thus internally the <code>QGraphicsWidget::setGeometry</code>  call early outs, based on the following code from qgraphicswidget.cpp Ln. 344</p>
<pre><code>if (newGeom == d-&gt;geom)
   return;
</code></pre>
<p dir="auto">However the rest of my code depends on signals that are emitted from within the setGeometry function,<br />
and in this edge case, parts of my GUI don't get drawn in correctly.</p>
<p dir="auto">So my question is:<br />
Is there a easy / cheap way to force the internal setGeometry function to fully execute?<br />
I've tried the following</p>
<pre><code>            mGraphicsWidget-&gt;layout()-&gt;setInstantInvalidatePropagation(true);
            mGraphicsWidget-&gt;layout()-&gt;invalidate();
</code></pre>
<p dir="auto">But it doesn't do what I need.<br />
Doing a...</p>
<pre><code>            mGraphicsWidget-&gt;resize(0, 0);
</code></pre>
<p dir="auto">Prior to the resize, DOES work, but it seems like an unnecessary duplication of work?</p>
<p dir="auto">Is there a faster, more effective way of modifying the internal state of the QGraphicsWidget,<br />
( ie. the <code>QGraphicsLayoutItemPrivate d-&gt;geom</code>  that will allow the actual setGeometry to fully execute?)</p>
<p dir="auto">Cheers,<br />
James</p>
]]></description><link>https://forum.qt.io/topic/164557/forcing-qgraphicswidget-setgeometry-to-execute....</link><generator>RSS for Node</generator><lastBuildDate>Thu, 23 Apr 2026 07:14:30 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/164557.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 14 Apr 2026 05:04:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Forcing QGraphicsWidget::setGeometry to execute....? on Sun, 19 Apr 2026 22:32:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jeremy_k">@<bdi>jeremy_k</bdi></a></p>
<p dir="auto">Yeah it's increasingly looking like this is the case.<br />
It's a pretty rare edge case in the code, so I need to consider if a larger refactor is worth the time and effort.</p>
]]></description><link>https://forum.qt.io/post/837867</link><guid isPermaLink="true">https://forum.qt.io/post/837867</guid><dc:creator><![CDATA[Jammin44fm]]></dc:creator><pubDate>Sun, 19 Apr 2026 22:32:20 GMT</pubDate></item><item><title><![CDATA[Reply to Forcing QGraphicsWidget::setGeometry to execute....? on Sat, 18 Apr 2026 09:54:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jammin44fm">@<bdi>Jammin44fm</bdi></a> said in <a href="/post/837702">Forcing QGraphicsWidget::setGeometry to execute....?</a>:</p>
<blockquote>
<p dir="auto">However the rest of my code depends on signals that are emitted from within the setGeometry function,</p>
</blockquote>
<p dir="auto">My instinct is that the rest of the code is wrong. Signaling a geometry change appears to be used as a proxy for something else. What is that something else?</p>
]]></description><link>https://forum.qt.io/post/837848</link><guid isPermaLink="true">https://forum.qt.io/post/837848</guid><dc:creator><![CDATA[jeremy_k]]></dc:creator><pubDate>Sat, 18 Apr 2026 09:54:35 GMT</pubDate></item><item><title><![CDATA[Reply to Forcing QGraphicsWidget::setGeometry to execute....? on Thu, 16 Apr 2026 07:51:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jammin44fm">@<bdi>Jammin44fm</bdi></a> said in <a href="/post/837702">Forcing QGraphicsWidget::setGeometry to execute....?</a>:</p>
<blockquote>
<p dir="auto">Is there a easy / cheap way to force the internal setGeometry function to fully execute?</p>
</blockquote>
<p dir="auto">Forcing a complete re-draw with new geometry is never "cheap" or efficient. That would also require <code>prepareGeometryChange()</code> to be called, so the view/scene knows what is going to happen next.<br />
Most <code>QGraphicsItems</code> invalidate their boundingRect in this case and re-create it on next <code>paint()</code> with updated geometry and matching content.</p>
]]></description><link>https://forum.qt.io/post/837785</link><guid isPermaLink="true">https://forum.qt.io/post/837785</guid><dc:creator><![CDATA[Pl45m4]]></dc:creator><pubDate>Thu, 16 Apr 2026 07:51:57 GMT</pubDate></item><item><title><![CDATA[Reply to Forcing QGraphicsWidget::setGeometry to execute....? on Tue, 14 Apr 2026 07:32:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jammin44fm">@<bdi>Jammin44fm</bdi></a> said in <a href="/post/837702">Forcing QGraphicsWidget::setGeometry to execute....?</a>:</p>
<blockquote>
<p dir="auto">if (newGeom == d-&gt;geom)<br />
return;</p>
</blockquote>
<p dir="auto">Given this I assume you <em>need</em> to have a changed geometry.  Use an <code>adjustSize()</code> or temporarily set its geometry to 1 more or less than it should be and set it back.  Or change whatever in your code so that it does not need a <code>setGeometry</code> signal where it has not actually changed.</p>
]]></description><link>https://forum.qt.io/post/837715</link><guid isPermaLink="true">https://forum.qt.io/post/837715</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 14 Apr 2026 07:32:13 GMT</pubDate></item><item><title><![CDATA[Reply to Forcing QGraphicsWidget::setGeometry to execute....? on Tue, 14 Apr 2026 06:31:32 GMT]]></title><description><![CDATA[<p dir="auto">I've also discovered that<br />
<code>~mGraphicsWidget-&gt;adjustSize();</code><br />
has the desired effect, But i see that internally this is just doing a setGeometry() with the preferred size for this object - so we are still doing a 2 setGeometry() calls :(</p>
]]></description><link>https://forum.qt.io/post/837708</link><guid isPermaLink="true">https://forum.qt.io/post/837708</guid><dc:creator><![CDATA[Jammin44fm]]></dc:creator><pubDate>Tue, 14 Apr 2026 06:31:32 GMT</pubDate></item></channel></rss>