Important: Please read the 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 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.

  • @maxwell31 Add in Dialog component

    Dialog {
        width: 400

    The error will go away.

Log in to reply