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

[REG 5->6]QML Customised scrollbar has incorrect size and scrolling behaviour

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.1.1, 6.2.0 Alpha
    • 6.0.1, 6.1.0 Beta2
    • Quick: Controls 2
    • None
    • macOS
    • 2261054c490c60cf297adf684855a634826f5813 (qt/qtquickcontrols2/dev) e9d766d9c8790f85191e8be4bb9feaeb0a997c9b (qt/qtquickcontrols2/6.1)

    Description

      Porting from QML in Qt 5.15 to Qt 6 shows failure of customized scrollbar sizing attached to a ListView.  I have discovered the issue with MacOS 10.15.7 and I don't know where it exists elsewhere.   I create a minimal custom ScrollBar and attach it to a ListView. The scroll indicator works fine in 5.15 but in 6.x the scroll indicator fills the entire scroll regardless of whether or not it should.

      I create CustomScrollbar.qml as follows:

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      ScrollBar {
          contentItem: Rectangle {
              implicitWidth: 15
              color: "red"
          }
      }
      

      and then use it in a basic ListView:

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Controls 2.15
      Window {
          width: 300; height: 100; visible: true
      
          ListView {
              id:listView
              anchors.fill:parent
              ScrollBar.vertical: CustomScrollbar {}
      
              model: ListModel {
                  ListElement {name: "Bill"} ListElement {name: "Bob"} ListElement {name: "Andy"} ListElement {name: "Jim"}
                  ListElement {name: "Ralph"} ListElement {name: "Ed"} ListElement {name: "Bill"} ListElement {name: "Bill"}
              }
             delegate: Text {
                 text: name
             }
          }
      }
      

      This code works fine in Qt 5.15 but in Qt 6.0.2 and 6.1.0 there are sizing issues and scrolling fails.

       

      Picture shows 5.15 expected behavior (left)and 6.x (right)

      There is also an error related to native controls:

      "...Qt6/6.0.2/clang_64/qml/QtQuick/Controls/macOS/ScrollBar.qml:61:49: Unable to assign [undefined] to int" and that is

      Behavior on opacity { 
        NumberAnimation
        {
          duration: contentItem.transitionDuration 
        }
      }
      

      but defining such a property for contentitem in the control doens't seem to change anything substantitve.

      Error behavior, in summary appears to be:

      1. Custom ScrollBar on listview fills entire region when the height does not reach beyond all items . In this configuration, the scrollbar cannot be dragged. Dragging the items causes fast and erratic behavior on the scrollbar
      2. When the height of the listview encompasses all items, the scrollbar handle has ZERO height, dragging up and down apparently causes the top and bottom of the scrollbar handle to flip to the top then bottom of the control.
      3. Some requirement related to native controls requires a transitionDuration in a minimal listview-with-scrollbar setup
      4. No documentation appears to document this behavior change, the unknown interaction with  native controls, etc.

       

      Attachments

        For Gerrit Dashboard: QTBUG-92158
        # Subject Branch Project Status CR V

        Activity

          People

            mitch_curtis Mitch Curtis
            steveqtr Stephen Conover
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes