2016-07-22 7 views
1

次の要素の幅が指定されたレイアウトの幅を超える場合、QMLレイアウトまたはQMLアイテムを次の行に自動的に折り返す設定がありますか?QMLレイアウトの要素の自動行ラッピング

私はQML GridLayoutを使用すると、アイテムがちょうどウィンドウの端をオフに行くと、クリップされています。

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]

私は"Scalability"ラベルされたQtのドキュメントページを見てみると、私は非常に手動スケーリングを見ます行っている。基本的に、彼らは必要な列を計算する必要があることを示唆しています。

アイテムの自動折り返しを行うレイアウトタイプや設定がありますか?

答えて

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

パーフェクト。ありがとう。私はこれが存在するようなものを知っていた。 –