Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-126042

Nested ListView of orthogonal orientation gets stuck without snapping using touchpad

    XMLWordPrintable

Details

    • Linux/Wayland, macOS
    • c3a1a9158 (dev), 39dfd69e7 (6.8), 2435e1625 (6.7), 3d88b696c (tqtc/lts-6.5)

    Description

      Background

      Suppose you have a ListView whole delegates are also ListView items but with an orthogonal orientation. In my minimal reproducible example I chose a horizontal top-level view and vertical nested views. Each view is set to snapMode: ListView.SnapOneItem.

      Problem

      On Wayland only, vertical scrolling snaps the inner views alright, but horizontal scrolling makes the top-level view stuck without snapping wherever when you lift off your fingers from a touchpad — presumably because an inner view consumes the touch up event, so the top-level view still "thinks" it is being flicked. As a side-effect, it also stops reacting to the external changes to currentIndex.

      Workaround

      Another usability issue which is common to both X11 and Wayland is that both top-level and nested flickable views would receive and process scrolling events, possibly moving in the orthogonal directions at the same time. At least in my case this is not desirable, and luckily it is possible to cross-block interactivity whenever a view of an orthogonal direction is moving. Since event processing is disabled for non-interactive views, it also "fixes" the snapping issue.

      ListView {
          id: topLevel
      
          interactive: {
              for (let i = 0; i < count; i++) {
                  const item = itemAtIndex(i) as ListView;
                  if (item && item.moving) {
                      return false;
                  }
              }
              return true;
          }
      
          delegate: ListView {
              id: nested
      
              interactive: !topLevel.moving
          }
      }
      

      Although, I don't feel like that binding with itemAtIndex is particularly reliable. It could've been better with attached properties and an aggregate object, like the one I implemented in KItemModels framework: https://invent.kde.org/frameworks/kitemmodels/-/merge_requests/89

      Additional Information

      Downstream bug report: https://bugs.kde.org/show_bug.cgi?id=477616

      Attachments

        1. nested-listview.qml
          2 kB
          ivan tkachenko
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            srutledg Shawn Rutledge
            ratijas ivan tkachenko
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes