Skip to content

PythonQt.QtGui.QWheelEvent · declarations 001

Back to PythonQt.QtGui.QWheelEvent

angleDelta

angleDelta() -> Any

X.angleDelta() -> PythonQt.QtCore.QPoint

Supplemental documentation: Qt 5 reference:

QPoint QWheelEvent::angleDelta() const

Returns the relative amount that the wheel was 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. angleDelta().y() provides the angle through which the common vertical mouse wheel was rotated since the previous event. angleDelta().x() provides the angle through which the horizontal mouse wheel was rotated, if the mouse has a horizontal wheel; otherwise it stays at zero. Some mice allow the user to tilt the wheel to perform horizontal scrolling, and some touchpads support a horizontal scrolling gesture; that will also appear in angleDelta().x().

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. But to provide a more native feel, you should prefer pixelDelta() on platforms where it's available.

Example:

void MyWidget::wheelEvent(QWheelEvent *event)
{
    QPoint numPixels = event->pixelDelta();
    QPoint numDegrees = event->angleDelta() / 8;

    if (!numPixels.isNull()) {
        scrollWithPixels(numPixels);
    } else if (!numDegrees.isNull()) {
        QPoint numSteps = numDegrees / 15;
        scrollWithDegrees(numSteps);
    }

    event->accept();
}

Note: On platforms that support scrolling phases, the delta may be null when:

  • scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
  • or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).

See also pixelDelta().

Upstream PySide2 reference signatures (binding differences may apply):

angleDelta(self) -> PySide2.QtCore.QPoint

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#angleDelta

buttons

buttons() -> Any

X.buttons()

Supplemental documentation: Qt 5 reference:

Qt::MouseButtons QWheelEvent::buttons() const

Returns the mouse state when the event occurred.

Upstream PySide2 reference signatures (binding differences may apply):

buttons(self) -> PySide2.QtCore.Qt.MouseButtons

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#buttons

delta

delta() -> int

X.delta() -> int

Upstream PySide2 reference signatures (binding differences may apply):

delta(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#delta

globalPos

globalPos() -> Any

X.globalPos() -> PythonQt.QtCore.QPoint

Upstream PySide2 reference signatures (binding differences may apply):

globalPos(self) -> PySide2.QtCore.QPoint

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#globalPos

globalPosF

globalPosF() -> Any

X.globalPosF() -> PythonQt.QtCore.QPointF

Upstream PySide2 reference signatures (binding differences may apply):

globalPosF(self) -> PySide2.QtCore.QPointF

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#globalPosF

globalX

globalX() -> int

X.globalX() -> int

Upstream PySide2 reference signatures (binding differences may apply):

globalX(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#globalX

globalY

globalY() -> int

X.globalY() -> int

Upstream PySide2 reference signatures (binding differences may apply):

globalY(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#globalY

orientation

orientation() -> Any

X.orientation()

Upstream PySide2 reference signatures (binding differences may apply):

orientation(self) -> PySide2.QtCore.Qt.Orientation

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#orientation

phase

phase() -> Any

X.phase()

Supplemental documentation: Qt 5 reference:

Qt::ScrollPhase QWheelEvent::phase() const

Returns the scrolling phase of this wheel event.

Note: The Qt::ScrollBegin and Qt::ScrollEnd phases are currently supported only on macOS.

This function was introduced in Qt 5.2.

Upstream PySide2 reference signatures (binding differences may apply):

phase(self) -> PySide2.QtCore.Qt.ScrollPhase

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#phase

pixelDelta

pixelDelta() -> Any

X.pixelDelta() -> PythonQt.QtCore.QPoint

Supplemental documentation: Qt 5 reference:

QPoint QWheelEvent::pixelDelta() const

Returns the scrolling distance in pixels on screen. This value is provided on platforms that support high-resolution pixel-based delta values, such as macOS. The value should be used directly to scroll content on screen.

Example:

void MyWidget::wheelEvent(QWheelEvent *event)
{
    QPoint numPixels = event->pixelDelta();
    QPoint numDegrees = event->angleDelta() / 8;

    if (!numPixels.isNull()) {
        scrollWithPixels(numPixels);
    } else if (!numDegrees.isNull()) {
        QPoint numSteps = numDegrees / 15;
        scrollWithDegrees(numSteps);
    }

    event->accept();
}

Note: On platforms that support scrolling phases, the delta may be null when:

  • scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
  • or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).

Note: On X11 this value is driver specific and unreliable, use angleDelta() instead

Upstream PySide2 reference signatures (binding differences may apply):

pixelDelta(self) -> PySide2.QtCore.QPoint

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#pixelDelta

pos

pos() -> Any

X.pos() -> PythonQt.QtCore.QPoint

Upstream PySide2 reference signatures (binding differences may apply):

pos(self) -> PySide2.QtCore.QPoint

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#pos

posF

posF() -> Any

X.posF() -> PythonQt.QtCore.QPointF

Upstream PySide2 reference signatures (binding differences may apply):

posF(self) -> PySide2.QtCore.QPointF

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#posF

source

source() -> Any

X.source()

Supplemental documentation: Qt 5 reference:

Qt::MouseEventSource QWheelEvent::source() const

Returns information about the wheel event source.

The source can be used to distinguish between events that come from a mouse with a physical wheel and events that are generated by some other means, such as a flick gesture on a touchpad.

Note: Many platforms provide no such information. On such platforms Qt::MouseEventNotSynthesized is returned always.

This function was introduced in Qt 5.5.

See also Qt::MouseEventSource.

Upstream PySide2 reference signatures (binding differences may apply):

source(self) -> PySide2.QtCore.Qt.MouseEventSource

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#source

x

x() -> int

X.x() -> int

Upstream PySide2 reference signatures (binding differences may apply):

x(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#x

y

y() -> int

X.y() -> int

Upstream PySide2 reference signatures (binding differences may apply):

y(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qwheelevent.html#y