Mouse wheel event's angleDelta().y() always 0 with Alt key modifier

Tobias Megies megies at geophysik.uni-muenchen.de
Fri Nov 25 09:01:39 GMT 2022


Hi all,

I'm experiencing a bug with pyqt, although to be fair, I can not say if 
it is a pyqt or qt problem. I reported this in the wrong place first so 
please look at this for more detailed description: 
https://github.com/pyqt/python-qt5/issues/73

When Alt key is held down, mouse wheel events always report 0 for 
"angleDelta().y()", i.e. it is impossible to tell in which direction the 
mouse wheel was scrolled. Not sure if Alt is the only affected modifier, 
in any case some other common keys like shift or control are not affected.

Minimal example code to reproduce:

"""
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QLabel, QMainWindow

class MainWindow(QMainWindow):
     def __init__(self):
         super().__init__()
         self.label = QLabel("scroll mouse wheel here")
         self.setCentralWidget(self.label)

     def wheelEvent(self, e):
         info = [
             "",
             "wheel event",
             "modifier: %d" % e.modifiers(),
             "angleDelta.y: %d" % e.angleDelta().y(),
             ]
         self.label.setText('\n'.join(info))

app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()
"""

Steps to reproduce:
  - scroll mouse wheel over the shown label, shows +120 / -120 for
    scrolling up/down
  - scroll mouse wheel over the shown label with Alt key held down, shows
    0 / 0 scrolling up/down


Just verified bug is still present in most recent versions available 
through conda-forge.

pyqt                      5.15.7          py311h3408d8f_2    conda-forge
pyqt5-sip                 12.11.0         py311ha362b79_2    conda-forge
qt-main                   5.15.6               h7acdfc8_2    conda-forge


best,
Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pyqtbug.py
Type: text/x-python
Size: 605 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20221125/842e16a4/attachment.py>


More information about the PyQt mailing list