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

Flickable::contentY is incorrect if Flickable is anchored to a non-root object and has top/bottom margins

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.7.0
    • None

    Description

      This is a regression from Qt 4.

      This makes a scroll bar based on contentY position incorrectly. Workaround is to anchor to the root object. Output of program below is
      qml: onContentYChanged -304.79999999999995

      import QtQuick 2.0
      
      Item{      
          width: 569;  height: 762    
          
          Rectangle{//NO PROBLEM IF WE COMMENT THIS Rectangle OUT
              anchors.fill: parent
              
              ListView{
                  id: listView
                  
                  anchors{fill: parent;  topMargin: 1}//NO PROBLEM WITH topMargin: 0
                  onContentYChanged: print('onContentYChanged', contentY)
                  
                  model: 10
                  
                  delegate: Text{
                      width: listView.width;  height: listView.height / 5            
                      text: modelData
                  }
                  
                  Rectangle{//scrollbar
                      color: 'red'
                      width: 0.01 * parent.width;  radius: width / 2
                      anchors{right: parent.right;  margins: radius}
                      height:  Math.max(parent.height / parent.contentHeight * parent.height - 2 * radius, 20)//minimum height for large lists
                      y:       parent.contentY / parent.contentHeight * parent.height + radius
                      visible: parent.height < parent.contentHeight
                  }
              }
          }
      }
      

      Attachments

        Issue Links

          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
              chriscortopassi Chris Cortopassi
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes