Why is WheelDelta = 120?

前端 未结 4 1238
無奈伤痛
無奈伤痛 2021-02-13 21:09

I\'m working with mouse events, specifically OnMouseWheel. Many code samples refer to distance the view changes (or zoom f.i. in 3D application) as Distance =

4条回答
  •  臣服心动
    2021-02-13 21:42

    The Qt Documentation elaborates a bit more on why it is actually 120:

    QPoint QWheelEvent::angleDelta() const

    Returns the distance that the wheel is rotated, in eighths of a degree. A positive value indicates that the wheel was rotated forwards away from the user; a negative value indicates that the wheel was rotated backwards toward the user.

    Most mouse types work in steps of 15 degrees, in which case the delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.

    However, some mice have finer-resolution wheels and send delta values that are less than 120 units (less than 15 degrees). To support this possibility, you can either cumulatively add the delta values from events until the value of 120 is reached, then scroll the widget, or you can partially scroll the widget in response to each wheel event.

    https://doc.qt.io/qt-5/qwheelevent.html#angleDelta

提交回复
热议问题