编程语言
首页 > 编程语言> > python – 无法从Qt5中的QWheelEvent获取pixelDelta

python – 无法从Qt5中的QWheelEvent获取pixelDelta

作者:互联网

我从Qt4升级到Qt5(PyQt,具体而言)和QWheelEvent为我打破 – 它返回空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,而等效的Qt5方法是angleDelta.

标签:python,events,qt5,pyqt5,mousewheel
来源: https://codeday.me/bug/20190516/1114721.html