PDA

View Full Version : Scrolling QGraphicsView and QGraphicsScene



freely
18th February 2013, 18:37
Hi,

I have QGraphicsScene instance set to QGraphicsView on the GUI with scrollbars enabled and full view port update. But when I scroll my graphics view I get the items added to qgraphics scene disappeared on some point,

though they are added in code correctly and are expected to be displayed upon scroll ( custom class inherited from QGraphicsItem ):



class CSquare : public QObject, public QGraphicsItem


One can see how they disappear on application run on this video screen cast:

https://www.box.com/s/h4h94×1avgay1crzvyzx (https://www.box.com/s/h4h94×1avgay1crzvyzx)

Can somebody hint what is the problem, how to resolve so the graphics items will not disappear on the view?

Thanks in advance.

Santosh Reddy
18th February 2013, 21:15
As the link does not work, and with not much information I can only guess that you might have some problem with bounding rectangle

d_stranz
19th February 2013, 02:50
Why do you not derive your object from QGraphicsObject? It is essentially the same as you are doing manually now, and does it correctly.

But as Santosh says, without code we have no clue what you might be doing wrong.

freely
19th February 2013, 10:10
sorry for that incorrect link:
try this link for the video:
https://www.box.com/s/h4h94x1avgay1crzvyzx

Santosh Reddy
19th February 2013, 10:22
My player does not support .ogv files yet :(

So show us how do you implement CSquare class?

freely
19th February 2013, 13:37
Thank you. Santosh is absolutely right - the problem was in custom function in the inherited class:


QRectF boundingRect() const;

That should return valid rectangle. Now I fixed that in my project and m going to remove the video.

Thank you very much.

http://realvirtualdevelopment.co.nr.