Important: Please read the Qt Code of Conduct -

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:

    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)

    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!

  • Lifetime Qt Champion

    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())

  • @SGaist
    Thanks a lot. Instantiation using


    did the trick!
    Sorry that I missed that.

Log in to reply