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. Binding loop detected for width/height
QtWS25 Last Chance

Binding loop detected for width/height

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
gridviewbindingloopalign
2 Posts 2 Posters 2.4k 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
    Mark81
    wrote on last edited by
    #1

    I'm trying to setup a GridView in order to fill the available space with an integer number of cells. I can't reproduce the behavior of standard QWidget where the layouts resize according to the children sizes.

    I have:

    1. a Rectangle which is the "container" of my GridView
    2. the GridView gets the orientation of the rectangle and sets the cell size
    GridView {
            anchors.fill: parent
            cellWidth: Math.min(parent.width, parent.height) == parent.width ? parent.width / 3 : cellHeight
            cellHeight: Math.min(parent.width, parent.height) == parent.width ? cellWidth : parent.height / 2
            model: model
            delegate: delegate
        }
    

    it works, but at run-time I get:

    QML GridView: Binding loop detected for property "cellHeight"

    I don't understand why there is this loop. The assignments are mutually exclusive.

    By the way, how to center the GridView content? It fills the available space from left-to right.

    p3c0P 1 Reply Last reply
    0
    • M Mark81

      I'm trying to setup a GridView in order to fill the available space with an integer number of cells. I can't reproduce the behavior of standard QWidget where the layouts resize according to the children sizes.

      I have:

      1. a Rectangle which is the "container" of my GridView
      2. the GridView gets the orientation of the rectangle and sets the cell size
      GridView {
              anchors.fill: parent
              cellWidth: Math.min(parent.width, parent.height) == parent.width ? parent.width / 3 : cellHeight
              cellHeight: Math.min(parent.width, parent.height) == parent.width ? cellWidth : parent.height / 2
              model: model
              delegate: delegate
          }
      

      it works, but at run-time I get:

      QML GridView: Binding loop detected for property "cellHeight"

      I don't understand why there is this loop. The assignments are mutually exclusive.

      By the way, how to center the GridView content? It fills the available space from left-to right.

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by p3c0
      #2

      @Mark81
      The cellHeight when changes updates the cellWidth in this line:

      cellWidth: Math.min(parent.width, parent.height) == parent.width ? parent.width / 3 : cellHeight
      

      this cellWidth change re-evaluates the binding and updates the cellHeight in this line:

      cellHeight: Math.min(parent.width, parent.height) == parent.width ? cellWidth : parent.height / 2
      

      And this goes on foreever and hence the error.

      By the way, how to center the GridView content? It fills the available space from left-to right.

      How do you want it to appear ? Can you share some image ?

      157

      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