PDA

View Full Version : QGraphicsItem::update(); vs scene()->update();



Lord_Navro
24th April 2013, 23:19
Hi,

I'm trying to make an editor based on the diagramscene example (http://qt-project.org/doc/qt-4.8/graphicsview-diagramscene.html). I have a very similar arrow-updating technique as shown in the tutorial. However, I encountered problems while trying to update the arrow shape when the source/target item geometry changes. Here is the function that gets called


void ArcItem::geometryChanged()
{
computePath();
computePolygon();
computeShape();
update();
}

The arrow has a bit more complex shape which gets recomputed in the first three functions based on new positions. However, eventhough update() is called (and shape() is not isEmpty(), which I checked), sometimes, when moving the target graphicsItem arround for a while, the paint() method gets not called and the arrow simply disappears and then after some more dragging appears again. I failed to determine circumstances of these strange events and the only way I found to mage the arrows repaint correctly was to call scene()->update() which compromises performance greatly. The whole project is here https://github.com/LordNavro/CPNSimulator, the arrow graphics item is here https://github.com/LordNavro/CPNSimulator/blob/master/arcitem.cpp ...

Thanx for any suggestions.

wysota
25th April 2013, 06:23
QGraphicsItem::prepareGeometryChange()