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

Anchor loop when ScrollBar is bound to ListView's header and/or footer

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.2, 6.1.2
    • None
    • All

    Description

      Summary

      ScrollBar can't be anchored to header/footer of a ListView even if they are positioned as ListView.Overlay*.

      Description

      The thing that I wanted probably can be built using ColumnLayout, but for the hell of it I tried a ListView's natively supported propertied: header and footer. For simplicity's sake, let's leave out the footer for now. So, we have a ListView, a sticky header at the top, and a flickable content. Header always stays at the top, so naturally I tried to restrict ScrollBar's bounds to the actually scrollable area.

              ScrollBar.vertical: ScrollBar {
                  parent: listView
                  anchors.top: listView.top
                  anchors.bottom: listView.bottom
                  anchors.right: listView.right
                  anchors.topMargin: listView.headerItem ? listView.headerItem.implicitHeight : 0
                  anchors.bottomMargin: listView.footerItem ? listView.footerItem.implicitHeight : 0
      
                  policy: ScrollBar.AlwaysOn
              }
      

      It kinda succeeded for header (except ListView.OverlayHeader is broken, pretty much failed for footer (scrollbar is at full height). And left multiple identical warnings in console for both.

      Note that anchors are bound as margins to implicit sizes, not as top/bottom of the items themselves.

      Steps to reproduce

      Run the code in the attached example.

      Excepted output

      The code looks like it should work as it is. Especially given that header is an OverlayHeader, so it's size and position shouldn't change at all.

      Actual output

      qrc:/main.qml:35:29: QML ScrollBar: Possible anchor loop detected on vertical anchor.
      qrc:/main.qml:35:29: QML ScrollBar: Possible anchor loop detected on vertical anchor.
      qrc:/main.qml:35:29: QML ScrollBar: Possible anchor loop detected on vertical anchor.
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            ratijas ivan tkachenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes