2 Attachment(s)
Graphics scene doesn't repaint properly
I'm working with a graphics scene that can contain two types of QGraphicsItems: GraphicNodes and GraphicArcs. (Technically, GraphicNode inherits from QGraphicsRectItem because it made things easier for me but QGraphicsRectItems inherit from QGraphicsItem.) There are several types of GraphicNodes. Their only internal difference is their appearance.
Nodes can be attached to each other using arrows. (I have yet to implement arrow heads.) When I move a node and then try to drag it where it previously was, the arrow is no longer drawn correctly as shown in these screenshots and this blurry video: http://www.youtube.com/watch?v=AQ-bvwUJ9TY
Attachment 6232
Attachment 6233
Any thoughts on why this might happen? I didn't use QGraphicsItem's built-in "draggable item" support because I wanted to create a "ghost" preview during dragging. For the bounding rectangle of the arrows, I used the smallest possible rectangle that contains all begin/end points of the line pieces that form the arrow. As long as arrows stay out of the game, everything seems fine.
Re: Graphics scene doesn't repaint properly
If I understand Arrows are implemented by you. It looks like that QGraphicsItem::boundingRect of this arrow is incorrect or you do not call QGraphicsItem::prepareGeometryChange before value of boundingRect is changed.
Re: Graphics scene doesn't repaint properly
Quote:
Any thoughts on why this might happen?
Looks like the algorithm used to draw the arrow is not error free.
Without code however, its hard to say.
Re: Graphics scene doesn't repaint properly
Quote:
Originally Posted by
MarekR22
Hmm... I didn't know that I had to call QGraphicsItem::prepareGeometryChange before changing the bounding rectangle. Quite stupid actually, because the doc for QGraphicsItem::boundingRect states that if you want to change the item's bounding rectangle, you must first call prepareGeometryChange(). Oops... :(
Once again, I'm amazed at how you guys can pinpoint the cause of my problems with the little information I provide. Thanks!
Re: Graphics scene doesn't repaint properly
Are you able to post your code for this? I'm trying to do a similar thing with Arcs and Nodes. Are the nodes being logicially grouped in order as well?
Any help would be awesome.
Thanks
Re: Graphics scene doesn't repaint properly
Sorry... I can't post any code because the program I'm working on is a project for a Computer Science course. What do you mean with "logical grouping"?