Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-14711

QGraphicsView does not fully respect scrollbar policies set to Qt::ScrollBarAlwaysOff

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.0.0
    • 4.7.0
    • Widgets: GraphicsView
    • None
    • 28881c0c91aa53412fae32c52ab297c76e890971

    Description

      It looks as though there is a bug in the way QGraphicsView calculates the viewport rectangle when one of the scrollbars' policy is set to Qt::ScrollBarAlwaysOff.

      Test case (attached):

      • create a 100 x 400 rectangle item, and set the view's sceneRect to match this rectangle
      • set the vertical scrollbar's policy to "always on"
      • set the horizontal scrollbar's policy to "always off"
      • gently resize the graphics view until the point where the vertical scrollbar becomes active

      Expected result:

      • the vertical scrollbar allows you to scroll exactly until the end of the rectangle

      Actual result:

      • the vertical scrollbar allows you to scroll down beyond the end of the rectangle. The additional (unwanted) height is equal to the height which the horizontal bar would have occupied (although it's disabled).

      The cause is in QGraphicsViewPrivate::recalculateContentSize at line 397 in qgraphicsview.cpp, useHorizontalScrollBar can get set to "true" even though the policy is "always off". The same problem is true concerning the vertical scrollbar policy. I will submit a merge request for a suggested fix.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              bjnilsen Bjørn Erik Nilsen
              sharky Jeremy Lainé
              Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes