<?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[QGraphicsScene - not updated after QGraphicsItem moved]]></title><description><![CDATA[<p dir="auto">I have such situation. From QGraphicsItem::mouseMoveEvent method call QGraphicsScene::updateBarierMap. updateBarierMap method get positions of QGraphicsPolygonItem`s and generate grid map. But scene hold old position of items, not updated after item move. How to get updated values of items on scene after mouseMoveEvent or how to inform scene, that item position changed?</p>
<p dir="auto">Project svn url : <a href="https://freeman.svn.sourceforge.net/svnroot/freeman/qt4/trunk/qt4_book/sedgvik/path_a" target="_blank" rel="noopener noreferrer nofollow ugc">https://freeman.svn.sourceforge.net/svnroot/freeman/qt4/trunk/qt4_book/sedgvik/path_a</a></p>
]]></description><link>https://forum.qt.io/topic/10828/qgraphicsscene-not-updated-after-qgraphicsitem-moved</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 17:10:08 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/10828.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 28 Oct 2011 00:15:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QGraphicsScene - not updated after QGraphicsItem moved on Fri, 28 Oct 2011 09:59:33 GMT]]></title><description><![CDATA[<p dir="auto">Try to "update the geometry":<a href="http://doc.qt.nokia.com/latest/qgraphicsitem.html#prepareGeometryChange" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.nokia.com/latest/qgraphicsitem.html#prepareGeometryChange</a><br />
or you can set to scene this flag "QGraphicsScene::NoIndex":<a href="http://doc.qt.nokia.com/latest/qgraphicsscene.html#ItemIndexMethod-enum" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.nokia.com/latest/qgraphicsscene.html#ItemIndexMethod-enum</a> maybe this will be better for your dynamic scene.</p>
]]></description><link>https://forum.qt.io/post/114787</link><guid isPermaLink="true">https://forum.qt.io/post/114787</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 28 Oct 2011 09:59:33 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene - not updated after QGraphicsItem moved on Fri, 28 Oct 2011 09:58:36 GMT]]></title><description><![CDATA[<p dir="auto">bq. Perhaps you can show us the relevant pieces of code, instead of just pointing up to your application source and asking us to debug your problem? While a link to the full sources can come in handy, IMHO it is not a good thing to start with (just) that. bq.</p>
<p dir="auto">Andre, thanks for reply.</p>
<p dir="auto">This is relevant code that does not work properly.</p>
<p dir="auto">@<br />
void Scene::updateBarierMap()<br />
{<br />
foreach (QGraphicsItem* graphicsItem, items()) {<br />
Item* item = qgraphicsitem_cast&lt;Item*&gt; (graphicsItem);<br />
if (item) {<br />
QPolygonF polygon = item-&gt;polygon();</p>
<pre><code>                    // foreach polygon point construct line
</code></pre>
<p dir="auto">for (int index = 0; index &lt; polygon.size(); ++index) {<br />
int prevIndex = index - 1;<br />
if (prevIndex &lt; 0)<br />
prevIndex = polygon.size()-1;</p>
<pre><code>QLineF line (polygon[prevIndex], polygon[index]);
 
qDebug() &lt;&lt; "line " &lt;&lt; line.p1() &lt;&lt; line.p2();
</code></pre>
<p dir="auto">}<br />
}<br />
}<br />
}@</p>
<p dir="auto">And relevant code for Item class, that inherits from QGraphicsPolygonItem</p>
<p dir="auto">@<br />
void Item::mouseMoveEvent ( QGraphicsSceneMouseEvent * event )<br />
{<br />
QGraphicsItem::mouseMoveEvent(event);</p>
<p dir="auto">Scene* scene_ptr = qobject_cast&lt;Scene*&gt; (scene());<br />
if (scene_ptr) {<br />
scene_ptr-&gt;updateBarierMap();<br />
}<br />
}<br />
@</p>
<p dir="auto">When i call <em>scene_ptr-&gt;updateBarierMap();</em> scene doesn't update coordinates of Item. qDebug() return the same coordinates.</p>
<p dir="auto">How get from Scene::updateBarierMap() updated item coordinates?</p>
]]></description><link>https://forum.qt.io/post/114785</link><guid isPermaLink="true">https://forum.qt.io/post/114785</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 28 Oct 2011 09:58:36 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene - not updated after QGraphicsItem moved on Fri, 28 Oct 2011 08:27:17 GMT]]></title><description><![CDATA[<p dir="auto">Perhaps you can show us the <em>relevant</em> pieces of code, instead of just pointing up to your application source and asking us to debug your problem? While a link to the full sources can come in handy, IMHO it is not a good thing to start with (just) that.</p>
]]></description><link>https://forum.qt.io/post/114759</link><guid isPermaLink="true">https://forum.qt.io/post/114759</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Fri, 28 Oct 2011 08:27:17 GMT</pubDate></item></channel></rss>