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

Qml ListView increases/decreases contentY when delegates in List have different height and executing positionViewAtEnd()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P5: Not important P5: Not important
    • None
    • 5.0.1, 5.0.2
    • None

      Try this code:

      import QtQuick 1.1
      
      Rectangle
      {
          width: 360
          height: 360
      
          Text
          {
              id: contenty;
              objectName: "contenty";
      
      
              text: lv.contentY;
              anchors.top: parent.top
      
          }
      
          ListView
          {
              id: lv
              anchors.fill: parent
              anchors.bottomMargin: 30;
              anchors.topMargin: 30;
              spacing: 5
              clip: true;
      
              model: msgmodel
              delegate:
              Rectangle
              {
                  id: rect;
                  width: lv.width;
                  height: txt.height;
                  Text
                  {
                      id: txt;
      
                      width: 150;
                      anchors.top: parent.top;
                      anchors.topMargin: 5;
      
                      //wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
                      text: lv.contentHeight +  " " + msgtext;
                  }
              }
          }
      
          Text
          {
              id: btn;
              objectName: "btn";
      
              signal add();
      
              text: "Click to move at end"
              anchors.bottom: parent.bottom
              MouseArea
              {
                  anchors.fill: parent
                  onReleased:  lv.positionViewAtEnd();
              }
          }
      }
      

      If you use data that generate delegate items with same height it will work ok. But if you have text with different resulting height, every time when positionViewAtEnd() is called it will decrease (or in some cases increase) contentY to negative value when view is on top. I`ve also noticed if I use delegate items with same height but word wrap is enabled, same thing happens.
      In QtQuick 2.0 behavior is better - it only increases contentY on positionViewAtEnd when view is at the beginning. Case with word wrap is working well.

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

            aalpert Alan Alpert
            mixa Mihailo Milenkovic
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes