<?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[Issue with moving QGraphicsItem Fast]]></title><description><![CDATA[<p dir="auto">Hello,<br />
I do have a QGraphicsScene rendered in a QGraphicsView.<br />
I connected an horizontal slider position with the position of a QGraphicsItem, both added to the scene.<br />
The slider was added by using a QGraphicsProxyWidget.</p>
<p dir="auto">WHen I move the slider from left to right, the QGraphicsItem does the same.<br />
However, when moving the slider fast, from left to right, everything is smooth and perfect, from right to left the QGraphicsItem disappears sometimes while moving.</p>
<p dir="auto">Do you know why?</p>
<p dir="auto">I just connected this way</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/connect">@<bdi>connect</bdi></a>(slider,changePosition(int),mainwindow,SLOT(mySlotChangeItemPos(int)));@</p>
<p dir="auto">@mySlotChangeItemPos(int newposx){<br />
//<br />
//convert newposx to pixel value<br />
//<br />
myitem-&gt;setPos(newposx, 0);<br />
}@</p>
]]></description><link>https://forum.qt.io/topic/35293/issue-with-moving-qgraphicsitem-fast</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 09:14:37 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/35293.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 10 Dec 2013 08:40:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Issue with moving QGraphicsItem Fast on Wed, 11 Dec 2013 14:53:56 GMT]]></title><description><![CDATA[<p dir="auto">no idea? ;)</p>
]]></description><link>https://forum.qt.io/post/207040</link><guid isPermaLink="true">https://forum.qt.io/post/207040</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Wed, 11 Dec 2013 14:53:56 GMT</pubDate></item><item><title><![CDATA[Reply to Issue with moving QGraphicsItem Fast on Tue, 10 Dec 2013 22:46:06 GMT]]></title><description><![CDATA[<p dir="auto">Hello,<br />
Asperamanca : after some tests, it looks like its because of the bounding rect you were right ;)<br />
However, I dont know how to set it properly. I was thinking that the bounding rect doesnt need to update if you change the position.</p>
<p dir="auto">I have on my line :</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/void">@<bdi>void</bdi></a> Item::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)<br />
{<br />
QPen pen(Qt::black);<br />
pen.setWidth(2);</p>
<pre><code>QBrush brush(Qt::blue);
painter-&gt;drawLine(0,0,0,500);
</code></pre>
<p dir="auto">}</p>
<p dir="auto">QRectF Item::boundingRect() const<br />
{<br />
return QRectF(0,0,10,500);<br />
}@</p>
<p dir="auto">and in my window the slot:</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/void">@<bdi>void</bdi></a> MainWindow::changeXLinePos(int val)<br />
{<br />
int val2 = slid-&gt;style()-&gt;sliderPositionFromValue(0,1000,val,slid-&gt;width());<br />
qDebug() &lt;&lt; "val" &lt;&lt; val;<br />
qDebug() &lt;&lt; "pix" &lt;&lt; val2;<br />
item-&gt;setPos(treeWidget-&gt;header()-&gt;sectionPosition(3)+val2,0);<br />
}@</p>
<p dir="auto">How should I set the bounding rect correctly while the item s moving?<br />
Should I tale the new position as an attribute of the item, update the bounding rect after calling prepareGeometryChange?</p>
<p dir="auto">Thanks for your help !</p>
]]></description><link>https://forum.qt.io/post/206984</link><guid isPermaLink="true">https://forum.qt.io/post/206984</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 10 Dec 2013 22:46:06 GMT</pubDate></item><item><title><![CDATA[Reply to Issue with moving QGraphicsItem Fast on Tue, 10 Dec 2013 14:57:13 GMT]]></title><description><![CDATA[<p dir="auto">I used :<br />
int QStyle::sliderPositionFromValue ( int min, int max, int logicalValue, int span, bool upsideDown = false )</p>
<p dir="auto">to have a pixel value from the slider value as I want the line and the slider's header to align.</p>
]]></description><link>https://forum.qt.io/post/206936</link><guid isPermaLink="true">https://forum.qt.io/post/206936</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 10 Dec 2013 14:57:13 GMT</pubDate></item><item><title><![CDATA[Reply to Issue with moving QGraphicsItem Fast on Tue, 10 Dec 2013 14:53:24 GMT]]></title><description><![CDATA[<p dir="auto">what means "convert newposx to pixel value"? how do you do that?</p>
]]></description><link>https://forum.qt.io/post/206933</link><guid isPermaLink="true">https://forum.qt.io/post/206933</guid><dc:creator><![CDATA[NicuPopescu]]></dc:creator><pubDate>Tue, 10 Dec 2013 14:53:24 GMT</pubDate></item><item><title><![CDATA[Reply to Issue with moving QGraphicsItem Fast on Tue, 10 Dec 2013 11:47:39 GMT]]></title><description><![CDATA[<p dir="auto">Yes it is just what I do... I subclassed QGraphicsItem and added a drawLine in the paint method.<br />
My bounding rect is calculated correctly too .. It is not updated when the item moves but I think it should not, as its a local bouding rect.<br />
I cant have a look at the code right now (I am at work) but I am pretty sure its what I did.</p>
<p dir="auto">But cant it come from the intersection of the item (line) with the slider as you mentionned before?</p>
]]></description><link>https://forum.qt.io/post/206906</link><guid isPermaLink="true">https://forum.qt.io/post/206906</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 10 Dec 2013 11:47:39 GMT</pubDate></item><item><title><![CDATA[Reply to Issue with moving QGraphicsItem Fast on Tue, 10 Dec 2013 11:16:24 GMT]]></title><description><![CDATA[<p dir="auto">If all you do is calling setPos(), you shouldn't get this effect.<br />
What type does your QGraphicsItem have? If it's custom, are you sure the boundingRect is calculated correctly?</p>
]]></description><link>https://forum.qt.io/post/206904</link><guid isPermaLink="true">https://forum.qt.io/post/206904</guid><dc:creator><![CDATA[Asperamanca]]></dc:creator><pubDate>Tue, 10 Dec 2013 11:16:24 GMT</pubDate></item><item><title><![CDATA[Reply to Issue with moving QGraphicsItem Fast on Tue, 10 Dec 2013 10:18:55 GMT]]></title><description><![CDATA[<p dir="auto">bq. What do you actually do in the item's slot?</p>
<p dir="auto">I dont have item's slot, I just have a slot for my mainwindow which will move this item in the scene by using setPos() according to the slider's signal.</p>
]]></description><link>https://forum.qt.io/post/206899</link><guid isPermaLink="true">https://forum.qt.io/post/206899</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 10 Dec 2013 10:18:55 GMT</pubDate></item><item><title><![CDATA[Reply to Issue with moving QGraphicsItem Fast on Tue, 10 Dec 2013 10:15:59 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for your help :)<br />
The slider and the item are indeed touching each other as I want the QGraphicsItem ( a custom line) to make the continuation of the slider's handle.<br />
I will try what you are proposing, however, its weird that this only appears from right to left and not from left to right doesnt it?</p>
]]></description><link>https://forum.qt.io/post/206900</link><guid isPermaLink="true">https://forum.qt.io/post/206900</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 10 Dec 2013 10:15:59 GMT</pubDate></item><item><title><![CDATA[Reply to Issue with moving QGraphicsItem Fast on Tue, 10 Dec 2013 10:11:25 GMT]]></title><description><![CDATA[<p dir="auto">Are the slider and item very close to each other? If so, try out if the effect is still there if you put a bit of distance between then.</p>
<p dir="auto">What do you actually do in the item's slot?</p>
<p dir="auto">Since I don't know such flickering effects (at least on typical PC hardware), I suspect the slider being used via proxy item. Can you test what happens when the events are generated some other way, e.g. by a timer, not by the slider?</p>
]]></description><link>https://forum.qt.io/post/206898</link><guid isPermaLink="true">https://forum.qt.io/post/206898</guid><dc:creator><![CDATA[Asperamanca]]></dc:creator><pubDate>Tue, 10 Dec 2013 10:11:25 GMT</pubDate></item><item><title><![CDATA[Reply to Issue with moving QGraphicsItem Fast on Tue, 10 Dec 2013 10:03:10 GMT]]></title><description><![CDATA[<p dir="auto">Flickering effect indeed !</p>
]]></description><link>https://forum.qt.io/post/206895</link><guid isPermaLink="true">https://forum.qt.io/post/206895</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 10 Dec 2013 10:03:10 GMT</pubDate></item><item><title><![CDATA[Reply to Issue with moving QGraphicsItem Fast on Tue, 10 Dec 2013 10:00:41 GMT]]></title><description><![CDATA[<p dir="auto">"disappear" as in "never seen again", or are you talking about a flickering effect?</p>
]]></description><link>https://forum.qt.io/post/206892</link><guid isPermaLink="true">https://forum.qt.io/post/206892</guid><dc:creator><![CDATA[Asperamanca]]></dc:creator><pubDate>Tue, 10 Dec 2013 10:00:41 GMT</pubDate></item></channel></rss>