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

anchors.verticalCenter miscalculated with real height & y

    XMLWordPrintable

Details

    • fd23a222e (dev)

    Description

      Anchoring a rectangle to the verticalCenter of parent rectangle when both use real values for height / y seems to result in a miscalculation in the position.

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Controls 2.15
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Rectangle {
              id:rect2
              width: 100
              height : 41.2
              color: "light blue"
      
              Rectangle {
                  id:line2
                  anchors.verticalCenter: parent.verticalCenter
                  anchors.alignWhenCentered: false
                  width: 100
                  height: 0.9
                  color: "black"
                  onYChanged: console.log("Y, HEIGHT:", y, height)
              }
          }
      }
      

      The output would be: qml: Y, HEIGHT: 20.650000000000002 0.9.

      Steps to reproduce the problem:

      • Run the attached project

      Attachments

        1. listview-torture.qml
          2 kB
        2. qtbug95224.zip
          2 kB
        3. tweakable.qml
          2 kB

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              miikapernu Miika Pernu
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes