Solved QScroller "stateChanged" event not triggered
In my application, I have a QGraphicsView in which I can scoll Items using the QScroller:
self.graphicsScroller = QScroller() self.graphicsScroller.grabGesture(self.viewport(), self.graphicsScroller.TouchGesture)
This works pretty well. However, if I want to subscribe to the stateChanged event:
To trigger the scrollerStateChanged method:
@Slot(QScroller.State) def scrollerStateChanged(self, newState): print("scroller state changed")
This doesn't work.
I already tried the more convenient way by using QScroller without local reference:
QScroller.grabGesture(self.viewport(), QScroller.TouchGesture) QScroller.stateChanged.connect(self.scrollerStateChanged)
Works for scrolling, but stateChanged event is not triggered.
Additionally I tried with lambda expressions, but also no result.
Am I'm missing something here?
Thanks in advance for any help on this!
SGaist Lifetime Qt Champion last edited by
Hi and welcome to devnet,
I haven't used that class but based on the class documentation, I would guess the code should be something like:
QScroller.grabGesture(self.viewport(), QScroller.TouchGesture) scroller = QScroller.scroller(self.viewport()) scroller.stateChanged.connect(self.scrollerStateChanged)
Thanks a lot. Instantiation using
did the trick!
Sorry that I missed that.