PDA

View Full Version : QGraphicsScene and View scrolling problem



ithinkso
1st June 2011, 09:37
Hi,
I have a little problem with my QGraphicsView and QGraphicsScene when im scrolling. As you can see on pictures linked below i cliked this button to add Graph and some arrays, but something strange happened when i scrolling.

At top i see only Graph, to see arrays i must scroll down and i dont know why, it is possible to have this arrays all the time?

Pics to better understand my problem (only thing i did is changed scrollbar position)
http://img16.imageshack.us/img16/6522/screen1ard.png
http://img706.imageshack.us/img706/2315/screen2mr.png
http://img21.imageshack.us/img21/74/screen3tw.png

When im adding new items(graph or arrays) i simple resize QGraphicsScene (setSceneRectF) to oldsize+newitem.heigh and change newitem pos (setPos) to right place. It seems working only for 700px height i think, to see other i need to scroll down.

I add QGraphicsView into layout and then into centralWidget in mainwindow which i set to Qt::WindowMaximized so i think this might be a problem, how can i expand view to all visible area?

regards,
ithinkso

Santosh Reddy
2nd June 2011, 06:58
When im adding new items(graph or arrays) i simple resize QGraphicsScene (setSceneRectF) to oldsize+newitem.heigh and change newitem pos (setPos) to right place. It seems working only for 700px height i think, to see other i need to scroll down.
Not sure why you are setting the size of the scene, scene rectangle will automatically grows when items are added to or moved in the scene, setting it explicitly will restrict the view to show the area set (which I guess is a problem in your case)


I add QGraphicsView into layout and then into centralWidget in mainwindow which i set to Qt::WindowMaximized so i think this might be a problem, how can i expand view to all visible area?
If the view placed in a layout, and layout is set on to a widget, and widget is set as a central widget on the QMainWindow, then the view will automatically fit to all the available area on the main window.

ithinkso
2nd June 2011, 12:35
Thanks for reply, i figured out whats wrong except for you said, i was returning wrong boundingRect when i reimplemented this function for my graphicsitem classes and everythings works unexpected.

Problem solved, ty one more time.