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. QML Item: Binding loop detected for property "width"

QML Item: Binding loop detected for property "width"

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
bindingloop
2 Posts 2 Posters 27.0k 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.
  • I Offline
    I Offline
    Inviter42
    wrote on 8 Feb 2016, 15:08 last edited by
    #1

    Hi folks!
    I'm experiencing 'Binding loop' error and can't find where's the trouble. Compiler says: qrc:/main.qml:26:5: QML Item: Binding loop detected for property "width".
    Here's my code:

    import QtQuick 2.3
    import QtQuick.Window 2.2
    import QtQuick.Controls 1.4
    
    ApplicationWindow{
        id: applicationWindow1
        width: container.width + 2*margins
        height: container.height + 2*margins
        title: "Lab5"
        visible: true
        property int margins: 4
    
        Connections{
            target: transitionPoint
            onSendDataToQml: {
                outputText.text = outStr
            }
        }
        MouseArea {
            anchors.fill: parent
            onClicked: {
                transitionPoint.receiveDataFromQml(dataInputField.text)
            }
        }
    
        Item {
            id: container
            width: childrenRect.width
            height: childrenRect.height
            anchors.verticalCenter: parent.verticalCenter
            anchors.horizontalCenter: parent.horizontalCenter
    
            Text {
                id: outputText
                text: "Lambda"
                wrapMode: Text.WordWrap
                textFormat: Text.PlainText
                verticalAlignment: Text.AlignVCenter
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.top: parent.top
            }
    
            TextField{
                id: dataInputField
                width: 110
                placeholderText: "enter fraction data"
                anchors.horizontalCenter: outputText.horizontalCenter
                anchors.top: outputText.bottom
                anchors.topMargin: 3
            }
        }
    }
    
    
    

    Any suggestions are appreciated :)

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Charby
      wrote on 8 Feb 2016, 21:54 last edited by
      #2

      The binding loop comes from the container item where you ask the container to be of the size of its content whereas you size its content according to the parent size.

      You can either define the container dimensions as followed :

      width: dataInputField.width
      height: outputText.height + dataInputField.height
      

      but I would feel more natural to do the other way around : define the container dimension and then compute child element dimension according to the parent.

      1 Reply Last reply
      2

      2/2

      8 Feb 2016, 21:54

      • Login

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