Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved QScroller "stateChanged" event not triggered

    Qt for Python
    2
    3
    135
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      stroblme last edited by

      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:

      self.graphicsScroller.stateChanged.connect(self.scrollerStateChanged)
      

      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!

      1 Reply Last reply Reply Quote 0
      • SGaist
        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)
        

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        S 1 Reply Last reply Reply Quote 1
        • S
          stroblme @SGaist last edited by

          @SGaist
          Thanks a lot. Instantiation using

          QScroller.scroller(self.viewport) 
          

          did the trick!
          Sorry that I missed that.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post