Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
QML布局中元素的自动换行_Qml_Qt5_Qtquick2 - Fatal编程技术网

QML布局中元素的自动换行

QML布局中元素的自动换行,qml,qt5,qtquick2,Qml,Qt5,Qtquick2,如果下一个元素的宽度超过指定布局的宽度,是否有QML布局或某些配置会自动将QML项包装到下一行 当我使用a时,项目刚好离开窗口边缘并被剪裁: GridLayout { id: header_focused_container; width: parent.width; anchors.margins: 20; Text { text: "header_focused_container.width=" + header_f

如果下一个元素的宽度超过指定布局的宽度,是否有QML布局或某些配置会自动将QML项包装到下一行

当我使用a时,项目刚好离开窗口边缘并被剪裁:

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" }
}

当我看Qt的文档页面时,我看到了非常手动的缩放。基本上,他们建议我需要计算所需的列

是否有某种布局类型或配置可以自动包装项目?

您可以使用:


完美的谢谢我知道这样的事情会存在。
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" }
    }
}