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

Using nested QtQuick Layouts with spacing generates binding loops

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.5.1, 5.6.0 Beta
    • Quick: Layouts
    • None
    • Windows 8.1 64bit, QtCreator 3.6.0
    • f55deac59 (dev), 55b1c49f8 (6.9), ec1e3bb09 (tqtc/lts-6.8), 9141bd2da (tqtc/lts-6.5)

    Description

      While trying to nest a RowLayout into a ColumnLayout, I encountered these warnings:

      <Unknown File>: QML QQuickLayoutAttached: Binding loop detected for property "preferredWidth"

      Here is an example which generates three such warnings:

      import QtQuick 2.5
      import QtQuick.Layouts 1.2
      
      Rectangle {
          id: component_root
      
          width: 600
          height: 400
      
          ColumnLayout {
              width: parent.width
      
              RowLayout {
                  Layout.preferredWidth: parent.width
                  Layout.fillWidth: false
      
                  spacing: 5
      
                  Rectangle {
                      Layout.preferredWidth: 0.4 * parent.width
                      Layout.preferredHeight: 20
                      Layout.alignment: Qt.AlignCenter
                      color: "red"
                  }
      
                  Rectangle {
                      Layout.preferredWidth: 0.4 * parent.width
                      Layout.preferredHeight: 20
                      Layout.alignment: Qt.AlignCenter
                      color: "blue"
                  }
              }
          }
      }
      

      Changing spacing to 0 (instead of the current 5) gets rid of the warnings, but I don't understand why the warnings are generated in the first place and even less why they disappear when I set the spacing to 0. As far as I can see, there is no loop in the width, it's all top-down.

      Attachments

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

        Activity

          People

            smd Jan Arve
            bertb bertb
            Votes:
            12 Vote for this issue
            Watchers:
            16 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes