Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Dialog with Text as contentItem: Binding loop for property implicitWidth
Forum Updated to NodeBB v4.3 + New Features

Dialog with Text as contentItem: Binding loop for property implicitWidth

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by
    #1

    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.

    C 1 Reply Last reply
    1
    • M maxwell31

      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.

      C Offline
      C Offline
      Compozitor
      wrote on last edited by Compozitor
      #2

      @maxwell31 Add in Dialog component

      Dialog {
          width: 400
          ...
      

      The error will go away.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved