Binding loop detected for width/height
-
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:
- a Rectangle which is the "container" of my GridView
- 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.
-
@Mark81
ThecellHeight
when changes updates thecellWidth
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 thecellHeight
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 ?