Suppose I have a Grid, shows 4X4(4 rows and 4 columns), when I reduce the width by half, It should layout as 2X8. I search in Google, and I god some idea that, it can be achieve through calls of JavaScript to change dynamically, but I have unable to get the window size after re-size.
import QtQuick 2.2
Grid{
id:root
property int rootWidth:400//Created type to change using javascript
property int rootHeight:400//Created type to change using javascript
width:rootWidth
height:rootHeight
property int myRows: 4//Initially 4X4
property int myColumns: 4
rows: myRows
columns: myColumns
onWidthChanged:{ widthChange()}//Executed javascript, when width changes.
Repeater{
model:16
//Fixed Rectangle.
Rectangle{radius:36;width:100;height:100;color:"blue"}
}
function widthChange(){
//It seems, this condition failes, How to get the width of the
//window, after resizing the window?
if( root.width > 200 & root.width <400 )
{
//When width is less than 400 and greater than 200, set Grid as 2X4.
root.myColumns = 2;
root.myRows = 8;
root.rootWidth=200;
root.rootHeight= 800;
}
}
}
What I am try to achieve is, I need to fit the content( Fixed Rectangles ) in Grid/or any with scroll-bar according to device width. Can anyone help at least giving some hinds So i can work on this?, Appreciate if you know any alternative ways to achieve this?