PDA

View Full Version : graphicsview Problem



tampstaffs
7th February 2009, 15:12
HI,

I have been having some problems with graphics view.I tried to create a view which has 100 items.My problems are as follows:

1)Any small change sresults in 8 paint events.Can I somehow minimise them??
2)I would like to update only a part of the view sometimes can i do it??

Lykurg
7th February 2009, 15:43
1)Any small change sresults in 8 paint events.Can I somehow minimise them??
Well, without knowing your sourcecode, no one can say that.

2)I would like to update only a part of the view sometimes can i do it??
Please have a look at the docs QGraphicsView::ViewportUpdateMode (http://doc.trolltech.com/4.4/qgraphicsview.html#ViewportUpdateMode-enum) and QWidget::update( const QRect & r ) (http://doc.trolltech.com/4.4/qwidget.html#update-3)

Lykurg

wysota
7th February 2009, 20:20
2)I would like to update only a part of the view sometimes can i do it??

The view is by default updated only in those parts that map to the part of the scene containing modified items.

tampstaffs
7th February 2009, 22:35
hi ,
Thanks for the reply.

My problem is ,I have QGraphicsItems in the scene.When I try to update one of them, paint event is generated for it.And when it updates it self, for some reason its generating paint event fpr other items.I would like to minimise this, either to one paint event where all of them are updated at one time or that only th eitem I want is updated.

Aare there any tips and tricks to improve graphics view performance.When i start scrolling for example:
there are about 3 paint for each graphics items which is killing the performance.

I have created a scrollable area myself which inherits from QGraphicsWidget, Graphics items are added to this.but this multi paint events on the same items is proving costly during scrolling and even when application is being launched

wysota
7th February 2009, 23:08
My problem is ,I have QGraphicsItems in the scene.When I try to update one of them, paint event is generated for it.And when it updates it self, for some reason its generating paint event fpr other items.
This would suggest the boundingRect() for the item is defined incorrectly.


I would like to minimise this, either to one paint event where all of them are updated at one time or that only th eitem I want is updated.
They should all be updated at once (I mean in a single paintEvent() of the viewport). If you experience something different and you are sure about it then there is probably some error in your code.


Aare there any tips and tricks to improve graphics view performance.When i start scrolling for example:
there are about 3 paint for each graphics items which is killing the performance.
Hard to say exactly what is going on without seeing the code. But you may play around with QGraphicsItem::setCacheMode(), maybe it helps.



I have created a scrollable area myself which inherits from QGraphicsWidget, Graphics items are added to this.but this multi paint events on the same items is proving costly during scrolling and even when application is being launched

Can't you use what the graphics view offers? If you make your scene bigger than the view, scrollbars will appear by themselves. The reason for the behaviour you observe might be related to the fact that you use QGraphicsProxyWidget (if you do).

tampstaffs
8th February 2009, 13:49
Hi,

The problem is That I have a structure like this:

I have a QGraphicsWdget which is more or less acting as a container for all me items.
Than I have used qgridlayout and added all me items to it .this gridlayout is than set as child to the qgraphicswidget.

Now when i update any thing,its trying to paint all the scene items.I saw that using cache to gQGraphicItem would reduce repainting.
If so than where would be the best place to have it,QGraphicsWidget or to the items themselves??

wysota
8th February 2009, 19:59
Now when i update any thing,its trying to paint all the scene items.
That's probably the graphics widget item has to be repainted and that forces a repaint of all items that occupy its boundingRect() which means all items in your case.


If so than where would be the best place to have it,QGraphicsWidget or to the items themselves??

If all you want is a grid and you don't intend to resize the widget or anything, I'd suggest getting rid of QGraphicsWidget and positioning items yourself. Then only those items that get modified will get repainted.