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). I am on Win 7, so the warning about phases shouldn't apply to me. 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. What can I do?
From the Qt5 docs for QWheelEvent:
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.
There is no pixelData
in Qt4. It only has delta, and the equivalent Qt5 method to that is angleDelta.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With