View Full Version : No ScrollBar in QGraphicsView

20th August 2009, 11:29
Dear Friends
I have some QGraphicsItems in the QGraphicsScene which is visualized by QGraphicsView. I am doing some translation so that my item is getting out of the view.Some part is not visible. I am getting no horizontal scrollbar to see it..How could I set this mechanism so that whenever my items is out I should get a scrollbar.

20th August 2009, 11:38
Set properties :


20th August 2009, 11:39
take a look at QAbstractScrollArea::setHorizontalScrollBarPolicy/setVerticalScrollBarPolicy (http://doc.trolltech.com/4.5/qabstractscrollarea.html#horizontalScrollBarPolicy-prop).

20th August 2009, 15:38
Even if I put a scrollbar using setHorizontalScrollbarPolicy() then it's seen but I can't scroll if my item is translated and getting out of the view.
I think this is some other problem.I am not setting any setSceneRect for my view.Do I need to set always a rect using setSceneRect....What is the fundamental can anybody expliain me....

Whelese could be the reason. ??

21st August 2009, 14:06
I am facing the same problem, did you got any clue ??? pl. share.
Thank you.

21st August 2009, 14:17
Hi guys.
Please run this test code.
You will see, the scrollbars comes automatically. ;)
Because the GV cannot show the full line.
I hope you are getting my point.;)

#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>

int main(int argc, char *argv[])
QApplication a(argc, argv);
QGraphicsScene scene;
QGraphicsView view(&scene);
return a.exec();

26th August 2009, 09:02
Hi yogeshgokul,

If you add items from scene then it scrolls, that is fine.
The problem I am facing is I am drawing text using QPointer in QGraphicsView::drawForeground(), in this case the text gets cuts towards the rigth side of the view and it is not showing scrollbars.
do you have any idea for this case ?
Thank you.

26th August 2009, 09:11
You have to set the scene size properly and the scrollbars will appear.