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

QML Item does not handle (temporarily) invalid dimensions

XMLWordPrintable

    • All

      In the following code, I have contrived a situation where the height of a Rectangle is Infinite before becoming a valid value.

      import QtQuick
      import QtQuick.Window
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Rectangle {
              property real divisor: 0
              width: parent.width
              height: parent.height / divisor
              color: "green"
      
              Timer {
                  running: true
                  interval: 1000
                  onTriggered: parent.divisor = 1
              }
          }
      }

      While the height is Infinite, the Rectangle does not render, which is fine as the height is not valid. However once the height becomes a valid value, the Rectangle still fails to render.

      This situation can (and did) happen in a real and valid scenario where items were scaled by a factor that involved division by a constant, and the chance order in which elements were initialised by the QML engine resulted in the binding being setup and evaluated before the constant received its value.

      Can this be 'corrected' so that QML items can tolerate temporarily invalid dimensions (e.g. Infinite, NaN, negative x, y, width, height)?

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

            qtqmlteam Qt Qml Team User
            paulmasri Paul
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes