PDA

View Full Version : GraphicsView/GraphicsScene: scrollbar policy Qt::ScrollBarAsNeeded



Pieter from Belgium
10th November 2006, 13:02
In QGraphicsView, using the default scrollbar policy Qt::ScrollBarAsNeeded, I observe that the scrollbars do not always appear as needed. In border cases, they seem not to.

In particular, when one of both scrollbars is visible, the fact that this scrollbar is visible is not taken into account for determining when the other scrollbar must be displayed. For instance, when the horizontal scrollbar is visible, it may be the case that some of my contents is underneath the scrollbar, but not outside the window, without the vertical scrollbar is shown. That is, the content height would be entirely visible if the horizontal scrollbar would not be present.

And even if both scrollbars are visible, it is inpossible to scroll to the scene contents that lies the most to the right or the bottom of the scene.

Is this a bug, or am I doing something wrong?

jpn
10th November 2006, 13:35
Sounds like a bug. Could you provide a minimal compilable example?

Pieter from Belgium
10th November 2006, 15:02
It can easily be demonstrated using the following code:



...
QGraphicsScene* myscene = new QGraphicsScene();
myscene->addText("My very very long text line 1");
myscene->addText("My very very long text line 2")->setPos(QPointF(0,25));
QGraphicsView* myview = new QGraphicsView(myscene);
myview->show();
...


Now reduce the window width until the horizontal scrollbar. The entire text is reachable through the scrollbar.
Now reduce the window height until also the vertical scrollbar appears.
Two things can be noticed now:

The vertical scrollbar appears too late (as if the horizontal scrollbar was not visible).
The horizontal scrollbar is not adapted to make the content covered by the vertical scrollbar reachable (you can no longer scroll to the "2").


In short: using Qt::ScrollBarAsNeeded, a scrollbar does not take into account the area covered by the other scrollbar when it is visible.

Using Qt::ScrollBarAlwaysOn, the behavior is correct.

[This behavior shows in Qt 4.2.0 and 4.2.1.]

jpn
10th November 2006, 16:40
Although that's not compilable, the example is clear and even I can now see the problem. :) I couldn't find anything relevant on the Task Tracker (http://www.trolltech.com/developer/task-tracker) so I suggest you send a bug report to TT. Ship the example reproducing the problem in together with the textual bug report (just makes their life easier)..

Pieter from Belgium
21st March 2007, 13:15
I have rapported the bug to TrollTech and they have fixed it in 4.3.