例如,这个可以运行:
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.2
ApplicationWindow
{
visible: true
width: 640
height: 480
title: qsTr("Hello World")
function thingWidth()
{
return width*80/100
}
Column
{
spacing: 10;
anchors.horizontalCenter: parent.horizontalCenter
Thing { color: "red"; width: thingWidth(); }
Thing { color: "yellow"; width: thingWidth(); }
Thing { color: "green"; width: thingWidth(); }
}
}
将Column
更改为ColumnLayout
,窗口大小调整会导致布局错误。
需要任何帮助,谢谢。
编辑1:
这里也提供所请求的Thing.qml
.
import QtQuick 2.0
Item {
property alias color: rectangle.color
width: 50; height: 50
Rectangle
{
id: rectangle
border.color: "white"
anchors.fill: parent
}
}
看起来我的帖子大部分都是代码。是的,保姆,没错!那是因为人们在这里发布代码。
Thing
的代码,或者用我们可以访问到的东西(比如Rectangle
)替换它们。 - Mitch