Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. ListView overshoot limit
Qt 6.11 is out! See what's new in the release blog

ListView overshoot limit

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 702 Views
  • 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.
  • IntruderExcluderI Offline
    IntruderExcluderI Offline
    IntruderExcluder
    wrote on last edited by
    #1

    Is there any way to restrict user from infinite overshoot when flicking? I want to implement android-like refresh for ListView, problem is that I want to set some sort of maximum for vertical overshooting, but I do not see any property for that.

    Any ideas? Maybe I'm missing something?

    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by Markkyboy
      #2

      contentHeight?

      as an 'inherited member' of ListView: https://doc.qt.io/qt-5/qml-qtquick-flickable.html#contentHeight-prop

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      1 Reply Last reply
      0
      • IntruderExcluderI Offline
        IntruderExcluderI Offline
        IntruderExcluder
        wrote on last edited by IntruderExcluder
        #3

        Didn't get your idea. I mean I have an ListView with default bounds behaviour. Being at top of list I can drag its contents to a bottom direction, to simulate refresh request, like it is made in Android. The problem here is that I cannot restrict bottom dagging distance. Another problem is that I don't know ho to properly reset mouse grab.

        1 Reply Last reply
        0
        • IntruderExcluderI Offline
          IntruderExcluderI Offline
          IntruderExcluder
          wrote on last edited by
          #4

          Ok, just made it with a bit of C++ magic.

          ListView {
                  readonly property real maxOvershoot: 100
                  property bool resetting: false
          
                  boundsBehavior: contentY > 0 ? ListView.StopAtBounds : ListView.DragOverBounds // Overbound draggind allowed only at top of list
                  model: 20
          
                  onVerticalOvershootChanged: {
                      if (Math.abs(verticalOvershoot) >= maxOvershoot && !resetting) {
                          resetting = true;
                          returnToBounds();
                          Test.ungrab(this); // C++ grab trick
                      }
                  }
          
                  onContentYChanged: {
                      if (contentY === 0.0 && resetting) {
                          resetting = false;
                      }
                  }
          
                  delegate: Rectangle {
          ...
                  }
              }
          

          And C++ code is quite simple:

              Q_INVOKABLE void ungrab(QQuickItem* list) {
                  if (list != nullptr) {
                      list->ungrabMouse();
                      list->ungrabTouchPoints();
                  }
              }
          
          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