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

QWheelEvent::scenePosition() returns incorrect position.

    XMLWordPrintable

Details

    • All, Linux/Wayland, Linux/X11, Windows

    Description

      When calling scenePosition() on a QWheelEvent it returns the same as position(). This is different to e.g. QMouseEvent generated from key press, release, or move events, and also against the documented behavior.

      Here is what the documentation says:

      The scene position is the position relative to QQuickWindow if handled in QQuickItem::event(), in QGraphicsScene coordinates if handled by an override of QGraphicsItem::touchEvent(), or the window position in widget applications.

      However it returns the local position, relative to the current widget.

      I looked at the source-code and this is how the constructor of QWheelEvent looks like:

      QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF &globalPos, 
                               QPoint pixelDelta, QPoint angleDelta,
                               Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, 
                               Qt::ScrollPhase phase, bool inverted, 
                               Qt::MouseEventSource source, const QPointingDevice *device)
          : QSinglePointEvent(Wheel, device, pos, pos, globalPos, 
                              Qt::NoButton, buttons, modifiers, source),
            m_pixelDelta(pixelDelta), m_angleDelta(angleDelta)
      {...}
      

      It passes "pos, pos,global" to QSinglePointEvent, which expects "localPos, scenePos, globalPos". So it passes pos to both local and scene positions, not good.

      I think this should either be corrected, or there should be an change to the documentation that this functionality is different for this class.

      I looked at the other sub-classes of QSinglePointEvent. Both QHoverEvent and QTabletEvent also looks suspicious as well.

      Attachments

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

        Activity

          People

            srutledg Shawn Rutledge
            brugger Christian Brugger
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes