【发布时间】:2016-06-04 06:20:44
【问题描述】:
例如,这是有效的:
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
}
}
看起来我的帖子主要是代码。是的,保姆确实如此!那是因为人们在这里发布代码。
【问题讨论】:
-
请 a) 提供
Thing的代码,或 b) 将它们替换为我们可以访问的内容,例如Rectangle。 -
完成。对不起保姆