Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QScroller "stateChanged" event not triggered
Forum Updated to NodeBB v4.3 + New Features

QScroller "stateChanged" event not triggered

Scheduled Pinned Locked Moved Solved Qt for Python
3 Posts 2 Posters 400 Views 2 Watching
  • 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 Offline
    S Offline
    stroblme
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      1
      • SGaistS SGaist

        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)
        
        S Offline
        S Offline
        stroblme
        wrote on last edited by
        #3

        @SGaist
        Thanks a lot. Instantiation using

        QScroller.scroller(self.viewport) 
        

        did the trick!
        Sorry that I missed that.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved