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

QML ScrollBar Quick Controls 2 - policy: ScrollBar.AsNeeded not working when scrollbar is customized

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 6.3.0 Alpha
    • 5.10.0
    • Quick: Controls 2
    • None
    • 77d7e870bbc39c1d0a5d85e549d69015623df815 (qt/qtdeclarative/dev) cb0cdef62efa835beb49904c502189a420a4183c (qt/qtdeclarative/6.2)

    Description

      When ScrollBar is customized with contentItem, and contentHeight of ListView is smaller than ListView height, scrollbar is always visible and it's height is equal to ListView height, doesn't matter that policy: ScrollBar.AsNeeded is set. If contentHeight is bigger than ListView height, everything works fine. If ScrollBar is not customized, everything works fine too.

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      
      ApplicationWindow {
          id: window
          visible: true
          width: 640
          height: 480
      
          ListView {
              id: myListView
              width: 200
              height: 100
              model: 1
              spacing: 5
      
              delegate: Rectangle {
                  width: 200
                  height: 20
                  color: "red"
      
                  Text {
                      anchors.centerIn: parent
                      text: index
                      color: "white"
                  }
              }
      
              ScrollBar.vertical: ScrollBar {
                  id: scrollBar
                  policy: ScrollBar.AsNeeded
      
                  contentItem: Rectangle {
                      implicitWidth: 6
                      implicitHeight: 10
                      radius: width / 2
                      color: scrollBar.pressed ? "#81e889" : "#c2f4c6"
                  }
              }
          }
      }
      

      Attachments

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

        Activity

          People

            mitch_curtis Mitch Curtis
            cust0m1z3 Yordan Bonev
            Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes