[Interest] Synchronous painting on QGraphicsScene

Patrick Stinson patrickkidd at gmail.com
Sun Oct 8 05:03:09 CEST 2017



> On Oct 7, 2017, at 8:00 PM, Christian Gagneraud <chgans at gmail.com> wrote:
> 
> On 8 October 2017 at 06:27, Patrick Stinson <patrickkidd at gmail.com> wrote:
>> Hmm. Actually, I think that the elastic node example is implemented in the
>> same way as my app. Because of the delayed response of the “elasticity” in
>> the algorithm it is not possible to demonstrate a solution to my problem
>> even if it solved it.
>> 
>> Like the elastic node example, I am implementing QGraphicsItem::itemChange
>> for the node listening for QGraphicsItem::ItemPositionHasChanged, and then
>> updating the edges’s geometry just after calling ::prepareGeometryChange.
>> This queues an update for the next paint buffer, which is what causes my
>> problem.
> 
> If you can notice the time lag b/w the 2 paint events, it means that
> something is slow. Slow enough to cause a 20+ ms delay.
> So maybe your problem is elsewhere. Do you have this problem even
> without the opengl view?

What I mean is that this is visible if I move the mouse one pixel, or event more visible (and quite annoying) if I nudge the node (say, 10 pixels at a time) with the arrow keys.

> 
> If i'm not wrong, although the paint() on the edge item is not called
> within your mouse event of the node. the edge should be repainted
> right after the mouse event has finished, which should be a very short
> time period.
> 
> But maybe you’re talking about "paint buffer" in the OpenGL pipeline?

I think you had me right. I (sadly) don’t know anything about OpenGL!

> 
>> What I am wondering is if it is possible to implement painting in a
>> synchronous way, where all paint events which result from a single mouse
>> event are done in the same buffer frame.
> 
> Or maybe your python code is too slow to make the 2 paint event fits
> in a single buffer frame timeline.
> 
> Chris
> 
>> 
>> Make sense?
>> 
>> 
>> On Oct 7, 2017, at 1:01 AM, Christian Gagneraud <chgans at gmail.com> wrote:
>> 
>> On 7 October 2017 at 16:08, Patrick Stinson <patrickkidd at gmail.com> wrote:
>> 
>> Hi there!
>> 
>> I have a graph-ish diagram app where dragging some objects (like nodes)
>> necessitates dragging other objects (like connecting edges). However, if I
>> update an edge from the mouse event or ItemChanged(position) event then the
>> edge isn’t painted until the next paint event. At times, this is quite
>> obvious for example when nudging a node with an arrow key and the node is
>> going in one direction and edge goes in the other direction for one frame
>> because it is one buffer behind.
>> 
>> Any thoughts on synchronous painting?
>> 
>> 
>> Have you check the "Elastic node"  example? It does exactly what
>> you're describing. And last time i tried it, it worked very well, no
>> painting artifact.
>> How is your "update"  done exactly?
>> 
>> Chris
>> 
>> 
>> Thank you
>> -Patrick
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>> 
>> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1403 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20171007/85eaacc8/attachment.bin>


More information about the Interest mailing list