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

Binding loop detection fails on Dialog depending on order of imports

XMLWordPrintable

      Trying to instantiate a Dialog within a Component binding x,y properties will fail with a binding loop when the QtQuick.Controls import comes before  the QtQuick.Dialogs one.

      Steps to reproduce:

      • Run the attached project or the following code:
      // NOTE: Keep QtQuick.Controls before QtQuick.Dialogs in the imports
      
      import QtQuick 2.7
      import QtQuick.Controls 2.2
      import QtQuick.Dialogs 1.2
      
      Item
      {
          id: form
      
          Component
          {
              id: dialogComponent
              Dialog
              {
                  property alias name: dialogName.text
                  x: (parent.width - width) / 2
                  y: (parent.height - height) / 2
                  title: "Please choose a name"
                  standardButtons: Dialog.Ok | Dialog.Cancel
                  Row
                  {
                      anchors.verticalCenter: parent.verticalCenter
                      anchors.horizontalCenter: parent.horizontalCenter
                      spacing: 20
                      Label {
                          text: qsTr("Name")
                          verticalAlignment: Text.AlignVCenter
                          horizontalAlignment: Text.AlignHCenter
                      }
      
                      TextField {
                          id: dialogName
                          width: 217
                          horizontalAlignment: Text.AlignHCenter
                      }
                  }
              }
          }
      
          Button
          {
              id: button1
              x: 256
              y: 58
              text: qsTr("Press Me")
              onClicked:
              {
                  var dialog = dialogComponent.createObject(form)
                  dialog.visible = true
              }
          }
      }
      
      
      • Press the button and observe the following output:
      qrc:/Page1.qml:18:9: QML DefaultDialogWrapper: Binding loop detected for property "x"
      qrc:/Page1.qml:18:9: QML DefaultDialogWrapper: Binding loop detected for property "x"
      qrc:/Page1.qml:18:9: QML DefaultDialogWrapper: Binding loop detected for property "y"
      qrc:/Page1.qml:18:9: QML DefaultDialogWrapper: Binding loop detected for property "y"

      To workaround the issue just modify the order of the imports in this way:

      import QtQuick 2.7
      import QtQuick.Dialogs 1.2
      import QtQuick.Controls 2.2
      

      In this case the Dialog will be shown correctly.

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

            shausman Simon Hausmann
            ceztko Francesco Pretto
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes