내가 격자을 반으로 줄이면 4X4 (4 행 4 열)를 보여주고 있다고 가정 해 봅시다. 레이아웃은 2X8이어야합니다. 나는 구글에서 검색하고, 신이 어떤 아이디어를 가지고 있는지를 동적으로 바꿔 JavaScript로 호출 할 수는 있지만, 크기 이후에는 윈도우 크기를 얻을 수 없다.레이아웃 방법 창 너비를 조정할 때 창의 내용?
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;
}
}
}
은 무엇을 달성하려고하고, 나는 장치 폭에 따라 스크롤 막대 그리드 콘텐츠 (사각형 고정)/또는 맞게해야합니다. 누구나 최소한의 도움을 줄 수 있습니까?이 문제를 해결할 수 있습니까?, 이것을 달성하기위한 대안을 알고 계시다면 감사하겠습니다.
네, 그렇습니다. 스크롤바가 필요합니다. 이것은 훌륭한 대답이며, 나의 목적은 당신에 의해 단순화됩니다. 고맙습니다. – Ashif