Ok, this question has been asked before - but I didn't find an answer yet..
I'm trying to left/right swipe between images using a QLabel
but I didn't manage to receive any gesture events yet with my PyQt5 based application.
Here is what I have:
class MyViewer(QtWidgets.QLabel):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.setAttribute(QtCore.Qt.WA_AcceptTouchEvents) # just gave it a try
self.grabGesture(QtCore.Qt.SwipeGesture)
def event(self, event):
if event.type() == QtCore.QEvent.Gesture: # <= this won't happen
print("Hello event!")
return super().event(event)
I also tried to look for QtWidgets.QGestureEvent
but even when I just print out event.type()
I only see events seemingly unrelated to any gestures (except some QToucheEvent
instances)
Similar questions are this one, this one, this one and I even read some documentation but I didn't see a working example yet. Only questions and example C++ snippets..
I'm using PyQt5.15.0 for both Linux and Android and I didn't see a single trace of anything gesture-ish yet. What did I forget to do? Does the parent have to be set up somehow?