无法从 Qt5 中的 QWheelEvent 获取 pixelDelta

Cannot get pixelDelta from QWheelEvent in Qt5

我从 Qt4 升级到 Qt5(具体来说是 PyQt),QWheelEvent 对我来说坏了 - 它 returns 空 pixelDelta(),但相位为 2(默认)。我在 Win 7 上,所以关于阶段的警告不应该适用于我。当我 运行 此代码时:

from PyQt5 import QtWidgets


class Q(QtWidgets.QLabel):

    def wheelEvent(self, event):
        print(event.pixelDelta())

app = QtWidgets.QApplication([])
w = Q()
w.show()
app.exec_()

滚动打印 'PyQt5.QtCore.QPoint()' 没有坐标。我能做什么?

来自 QWheelEvent 的 Qt5 文档:

There are two ways to read the wheel event delta: angleDelta() returns the delta in wheel degrees. This value is always provided. pixelDelta() returns the delta in screen pixels and is available on platforms that have high-resolution trackpads, such as OS X.

Qt4中没有pixelData。它只有 delta, and the equivalent Qt5 method to that is angleDelta.