PDA

View Full Version : Strange behaviour in QGraphicsScene



yagabey
19th July 2011, 15:00
Hello All,

On a QGraphicsScene I have some items and I connect them via Arrow items(subclass of QGraphicsLineItem) like in DiagramEditor example...

Here is the problem:

I make my drawing. I save the items in an xml file. And then I load the xml file. Everything looks perfect till now. But After loading the items, when i try to make a new connection via arrow items, the arrows are added on the seen but they(the new ones) cannot be seen. I debug their visibility property, it is ok.. On the scene, when i move the scroll bar up and down they become visible ! Moreover I call the update function manually but paint event is not triggered..

Question:

What may I have done (during loading) to make arrow items behave like that? (I couldnt see anything strange)
Why doesnt paint event get called after update() ?(Although visible property true)

Thanks in advance..

Santosh Reddy
20th July 2011, 02:01
I guess you create a new QGraphicsLineItem, with scene as parent, it addition to this, make sure you add the newly created object of QGraphicsLineItem, to the scene using QGraphicsScene::addItem().

I assume you are referring to calling update() on the view. Calling update on the view is not required, the graphics scene will internally manage updating the view.