[英]Cannot get pixelDelta from QWheelEvent in Qt5
I upgraded from Qt4 to Qt5 (PyQt, to be specific) and QWheelEvent broke for me - it returns empty pixelDelta(), but phase is at 2 (default). 我从Qt4升级到Qt5(PyQt,具体而言)和QWheelEvent为我打破 - 它返回空pixelDelta(),但阶段是2(默认)。 I am on Win 7, so the warning about phases shouldn't apply to me.
我在Win 7上,所以关于阶段的警告不适用于我。 When I run this code:
当我运行此代码时:
from PyQt5 import QtWidgets
class Q(QtWidgets.QLabel):
def wheelEvent(self, event):
print(event.pixelDelta())
app = QtWidgets.QApplication([])
w = Q()
w.show()
app.exec_()
scrolling prints 'PyQt5.QtCore.QPoint()' without coordinates. 滚动打印'没有坐标的PyQt5.QtCore.QPoint()'。 What can I do?
我能做什么?
From the Qt5 docs for QWheelEvent : 从QT5文档的QWheelEvent :
There are two ways to read the wheel event delta: angleDelta() returns the delta in wheel degrees.
有两种方法可以读取车轮事件增量:angleDelta()以车轮度数返回增量。 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.
pixelDelta()以屏幕像素返回增量,可在具有高分辨率触控板的平台上使用,例如OS X.
There is no pixelData
in Qt4. Qt4中没有
pixelData
。 It only has delta , and the equivalent Qt5 method to that is angleDelta . 它只有delta ,而等效的Qt5方法是angleDelta 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.