2016-07-22 1 views
1

QML 레이아웃 또는 다음 요소의 너비가 지정된 레이아웃의 너비를 초과하는 경우 QML 항목을 다음 행으로 자동 줄 바꿈하는 구성이 있습니까? 나는 QML GridLayout를 사용하는 경우QML 레이아웃의 요소에 자동 행 줄이기

, 항목은 윈도우의 가장자리를 갈립니다 : 나는 라벨 Qt의 문서 페이지 "Scalability" 볼 때

GridLayout { 
    id: header_focused_container; 
    width: parent.width; 
    anchors.margins: 20; 
    Text { 
     text: "header_focused_container.width=" + 
      header_focused_container.width + 
      " and my width is =" + width 
    } 
    Rectangle { height:20; width:250; color: "red" } 
    Rectangle { height:20; width:250; color: "blue" } 
    Rectangle { height:20; width:250; color: "green" } 
} 

Gridlayout efforts[1]

내가 매우 매뉴얼 스케일링을 참조 계속. 기본적으로 필자는 필요한 열을 계산해야한다고 제안하고 있습니다.

항목의 자동 줄 바꿈을 수행 할 레이아웃 유형이나 구성이 있습니까?

답변

2

당신은 Flow를 사용할 수 있습니다

import QtQuick 2.5 
import QtQuick.Window 2.0 

Window { 
    visible: true 
    width: 400 
    height: 200 

    Flow { 
     id: header_focused_container 
     anchors.fill: parent 

     Text { 
      text: "blah" 
     } 
     Rectangle { height:20; width:250; color: "red" } 
     Rectangle { height:20; width:250; color: "blue" } 
     Rectangle { height:20; width:250; color: "green" } 
    } 
} 
+0

완벽한합니다. 감사. 나는 이것이 존재할 것임을 알았다. –

관련 문제