0
我有以下的定制Label
:访问QML嵌套变量成员从自定义标签
import QtQuick 2.3
import QtQuick.Controls 1.4
Label
{
anchors.centerIn: parent
text: "DashboardLabel!"
font.pixelSize: 22
font.italic: true
color: "steelblue"
Rectangle
{
id: rectangle
}
}
我想通过访问rectangle
x和y变量来更改标签的位置:
import QtQuick 2.3
import QtQuick.Controls 1.4
import CustomGraphics 1.0
Item
{
anchors.centerIn: parent
CustomLabel
{
id: customLabel
width: 100
height: 100
rectangle.x: 200
}
}
它似乎没有工作,因为我的自定义Label
没有移动。我应该使用property
功能吗?下面是我得到的错误:
Cannot assign to non-existent property "rectangle"
编辑:我只是试图以与rect.x
访问x
添加property alias rect: rectangle
。我没有得到任何错误,但没有出现在窗口上。