Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Error: Binding loop detected for property "width" .

    QML and Qt Quick
    3
    7
    970
    Loading More Posts
    • 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.
    • Bhushan_Sure
      Bhushan_Sure last edited by Bhushan_Sure

      Initially it is running fine but when i expand window ,this error is getting generated which is given as question
      Complete Code is given below

      import QtQuick 2.9
      import QtQuick.Window 2.3
      import QtCharts 2.3
      import QtQuick.Controls 1.4
      import QtQuick.Controls.Styles 1.4
      
      
      // Completed
      Rectangle
      {
          id:top
          visible: true
          width: 400
          height: 600
          color: "black"
      
          property double  x_variable_chrt_1: 0
          property double  y_variable_chrt_1: 0
      
          // ChartView 1
          ChartView
          {
              id:chrt
              height: top.height/3
              width: top.width+18.5
              x:-9.2
              antialiasing: true
              legend.visible: false
              backgroundRoundness: 0
              margins.top: 1
              margins.bottom: 1
              margins.left: 1
              margins.right: 1
              backgroundColor: "black"
      
              ValueAxis
              {
                  id:x_axis
                  min: 0
                  max: 50
                  tickCount: 6
                  visible: false
              }
      
              ValueAxis
              {
                  id:y_axis
                  min: 0
                  max: 5
                  tickCount: 6
                  visible: false
              }
      
              ValueAxis
              {
                  id:y_axis_right
                  min: 0
                  max: 5
                  tickCount: 6
                  visible: false
              }
      
              LineSeries
              {
                  id:l1
                  axisX: x_axis
                  axisY: y_axis
                  color: "#969FB2"
                  width: 3.5
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+0 }
              }
      
              LineSeries
              {
                  id:l2
                  axisX: x_axis
                  axisY: y_axis
                  color: "#969FB2"
                  width: 2
                  XYPoint { x: x_variable_chrt_1+10; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+10; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+20; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+20; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+30; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+30; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+40; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+40; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+5 }
              }
      
              LineSeries
              {
                  id:l3
                  axisX: x_axis
                  axisY: y_axis
                  color: "#969FB2"
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+3.34 }
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+3.34 }
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+1.67 }
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+1.67 }
                  style: Qt.DotLine
              }
          }
      
          // ChartView 2
          ChartView
          {
              id:chrt2
              height: top.height/3
              width: top.width+18.5
              x:-9.2
              antialiasing: true
              anchors.top: chrt.bottom
              legend.visible: false
              backgroundRoundness: 0
              margins.top: 15
              margins.bottom: 1
              margins.left: 1
              margins.right: 1
              backgroundColor: "black"
      
              ValueAxis
              {
                  id:x_axis_2
                  min: 0
                  max: 50
                  tickCount: 6
                  visible: false
              }
      
              ValueAxis
              {
                  id:y_axis_2
                  min: 0
                  max: 5
                  tickCount: 6
                  visible: false
              }
      
              ValueAxis
              {
                  id:y_axis_right_2
                  min: 0
                  max: 5
                  tickCount: 6
                  visible: false
              }
      
              LineSeries
              {
                  id:l1_2
                  axisX: x_axis
                  axisY: y_axis
                  color: "#969FB2"
                  width: 3.5
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+0 }
              }
      
              LineSeries
              {
                  id:l2_2
                  axisX: x_axis
                  axisY: y_axis
                  color: "#969FB2"
                  width: 2
                  XYPoint { x: x_variable_chrt_1+10; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+10; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+20; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+20; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+30; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+30; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+40; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+40; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+5 }
              }
      
              LineSeries
              {
                  id:l3_2
                  axisX: x_axis
                  axisY: y_axis
                  color: "#969FB2"
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+3.34 }
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+3.34 }
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+1.67 }
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+1.67 }
                  style: Qt.DotLine
              }
          }
      
          // ChartView 3
          ChartView
          {
              id:chrt3
              height: top.height/3
              width: top.width+18.5
              anchors.top: chrt2.bottom
              x:-9.2
              antialiasing: true
              legend.visible: false
              backgroundRoundness: 0
              margins.top: 15
              margins.bottom: 1
              margins.left: 1
              margins.right: 1
              backgroundColor: "black"
      
              ValueAxis
              {
                  id:x_axis_3
                  min: 0
                  max: 50
                  tickCount: 6
                  visible: false
              }
      
              ValueAxis
              {
                  id:y_axis_3
                  min: 0
                  max: 5
                  tickCount: 6
                  visible: false
              }
      
              ValueAxis
              {
                  id:y_axis_right_3
                  min: 0
                  max: 5
                  tickCount: 6
                  visible: false
              }
      
              LineSeries
              {
                  id:l1_3
                  axisX: x_axis
                  axisY: y_axis
                  color: "#969FB2"
                  width: 3.5
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+0 }
              }
      
              LineSeries
              {
                  id:l2_3
                  axisX: x_axis
                  axisY: y_axis
                  color: "#969FB2"
                  width: 2
                  XYPoint { x: x_variable_chrt_1+10; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+10; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+20; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+20; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+30; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+30; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+40; y: y_variable_chrt_1+0 }
                  XYPoint { x: x_variable_chrt_1+40; y: y_variable_chrt_1+5 }
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+5 }
              }
      
              LineSeries
              {
                  id:l3_3
                  axisX: x_axis
                  axisY: y_axis
                  color: "#969FB2"
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+3.34 }
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+3.34 }
                  XYPoint { x: x_variable_chrt_1+0; y: y_variable_chrt_1+1.67 }
                  XYPoint { x: x_variable_chrt_1+50; y: y_variable_chrt_1+1.67 }
                  style: Qt.DotLine
              }
          }
      
      }
      
      

      Any idea why this error ?

      Bhushan_Sure 1 Reply Last reply Reply Quote 0
      • Bhushan_Sure
        Bhushan_Sure @Bhushan_Sure last edited by

        @dheerendra @LeLev @Nikhilesh-N @J-Hilk Anything wrong i have done here ?

        J.Hilk ODБOï 2 Replies Last reply Reply Quote 0
        • J.Hilk
          J.Hilk Moderators @Bhushan_Sure last edited by

          Hi @Bhushan_Sure
          sadly I can't test your example, as soon as a add the 2nd Chartview, the application crashes. Works fine with 1, but not with 2 or more.

          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

          Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          Bhushan_Sure 1 Reply Last reply Reply Quote 1
          • ODБOï
            ODБOï @Bhushan_Sure last edited by ODБOï

            @Bhushan_Sure

            you can use layouts to get rid of Binding loop

            import QtQuick 2.12
            import QtQuick.Window 2.2
            import QtQuick.Controls 2.4
            import QtQuick.Window 2.3
            import QtQuick.Layouts 1.3
            import QtCharts 2.3
            import QtQuick.Controls.Styles 1.4
            
            ApplicationWindow {
                visible: true
                width: 640
                height: 480
            
               Component{
                   id:c
                ChartView {
            
                    antialiasing: true
                        ValueAxis {
                        id: axisX
                        min: 0
                        max: 10
                    }
                    ValueAxis {
                        id: axisY
                        min: 0
                        max: 1
                    }
            
                    LineSeries{
                        id:vals
                        axisX: axisX
                        axisY: axisY
                        visible: true
                        width:3
                        capStyle:  Qt.DashDotDotLine
                    }
            
                }
               }
            
               ColumnLayout{
                   anchors.fill: parent
                Loader{
                    sourceComponent: c
                    Layout.preferredHeight: parent.height/3
                    Layout.preferredWidth: parent.width
                }
                Loader{
                    sourceComponent: c
                    Layout.preferredHeight: parent.height/3
                    Layout.preferredWidth: parent.width
                }
                Loader{
                    sourceComponent: c
                    Layout.preferredHeight: parent.height/3
                    Layout.preferredWidth: parent.width
                }
               }
            }
            
            
            Bhushan_Sure 1 Reply Last reply Reply Quote 2
            • Bhushan_Sure
              Bhushan_Sure @J.Hilk last edited by

              @J.Hilk is it something wrong i have coded ? or anything you could suggest me ?

              1 Reply Last reply Reply Quote 0
              • Bhushan_Sure
                Bhushan_Sure @ODБOï last edited by

                @LeLev Ok I will try this code to run

                Bhushan_Sure 1 Reply Last reply Reply Quote 0
                • Bhushan_Sure
                  Bhushan_Sure @Bhushan_Sure last edited by Bhushan_Sure

                  @dheerendra @LeLev @J-Hilk
                  Hi i solved the issued
                  Thank you so much for your Valuable inputs.

                  Given code is :-

                  import QtQuick 2.9
                  import QtQuick.Window 2.3
                  
                  Window
                  {
                      visible: true
                      width: 400
                      height: 600
                      title: qsTr("Hello World")
                  
                      Loader
                      {
                          id:l1
                          source: "Graph_1.qml"
                          height: parent.height/3
                          width: parent.width
                      }
                  
                      Loader
                      {
                          id:l2
                          source: "Graph_2.qml"
                          height: parent.height/3
                          width: parent.width
                          anchors.top: l1.bottom
                      }
                  
                      Loader
                      {
                          id:l3
                          source: "Graph_3.qml"
                          height: parent.height/3
                          width: parent.width
                          anchors.top: l2.bottom
                      }
                  
                  }
                  

                  And Here Graph_1,Graph_2,Graph_3 are invidual graphs that i have to show.
                  that is 3 chartview.

                  1 Reply Last reply Reply Quote 2
                  • First post
                    Last post