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

Difficult to implement custom pan and zoom behaviour with QGraphicsView

    XMLWordPrintable

Details

    Description

      It took a long time to figure out how to compensate for how Qt aligns the scene rectangle within the view in QGraphicsViewPrivate::recalculateContentSize, and updates the scrollX and scrollY offset values in QGraphicsViewPrivate:updateScroll. We ended up finding a way to do this by re-implementing the virtual method scrollContentsBy, in order to counteract how Qt tried to impose an alignment. This was the only way we were able to implement our custom pan and zoom. We wanted to have:

      (1) No scroll bars
      (2) Arbitrary panning (even with the scene rectangle zoomed out)
      (3) Zoom to always scale about the centre of the view (and not necessarily the center of the scene rectangle)

      Custom scrolling would be much easier to do if QGraphicsView had an additional alignment option which was, say, Qt::AlignNone. In QGraphicsViewPrivate::updateScroll, if Qt::AlignNone was in effect, scrollX and scrollY would never be recomputed (and would be initialized to say, 0), and therefore, there would be no need to compute leftIndent and topIndent in QGraphicsViewPrivate::recalculateContentSize.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            mjro Marc Ouellette
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes