Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Dialog with Text as contentItem: Binding loop for property implicitWidth



  • Hi,

    I have an error dialog:

      Dialog {
          id: errorDialog
          objectName: "errorDialog"
          title: "Error"
          property string text: ""
          contentItem: TextStandard {
              text: errorDialog.text
          }
          modal: true
          focus: true
          anchors.centerIn: parent
          standardButtons: Dialog.Ok
    
          onAccepted: console.log("Ok clicked")
          onRejected: console.log("Cancel clicked")
      }
    

    which uses a customized text as contentItem:

    import QtQuick 2.12
    import Style 1.0
    
    Text {
        text: ""
        property int prefferedBlockWidth: Style.fontSizeStandard*Style.fontSizeStandard*Style.lineHeightFactor*Style.lineHeightFactor
        font.family: Style.fontNameStandard
        font.pixelSize: Style.fontSizeStandard
        font.letterSpacing: 0.25
        lineHeight: Style.lineHeightFactor*Style.fontSizeStandard
        lineHeightMode: Text.FixedHeight
        wrapMode: Text.WordWrap
    }
    
    

    If the dialog is shown, i get the error

    QML Dialog: Binding loop detected for property "implicitWidth"
    

    But I don't understand why.


Log in to reply