`QGraphicsView` scrolling with Trackpad is locked in x and y axis temporarily and no diagonal scrolling is possible
-
I am working with a
QGraphicsViewand I am looking for methods which may change the scrolling behaviour with a trackpad. I am able to scroll with the trackpad in x and y axis at the same time. What doesn't work is scrolling diagonal, the scrolling is locked to the x or the y axis, depending on, which movement happens first. I would like to be able to scroll diagonal as well. Maybe there are some methods likeQGraphicsView.setDragMode()which takes the corresponding constants to be able to remove the axis (x and y) locking while scrolling with the trackpad.
Only when scrolling very slowly with the trackpad a diagonal scrolling is somewhat possible.
-
Found a Solution by overriding
wheelEvent():from PyQt5.QtWidgets import QGraphicsView from PyQt5.QtGui import QWheelEvent class QDMGraphicsView(QGraphicsView): def wheelEvent(self, event: QWheelEvent): self.verticalScrollBar().setValue(self.verticalScrollBar().value() - event.pixelDelta().y()) self.horizontalScrollBar().setValue(self.horizontalScrollBar().value() - event.pixelDelta().x())Possibly
pixelDatais not available on all Operating Systems.