我正在为智能手机开发一个小应用程序,并且我有一个别名使用问题。 为了方便我在此代码段重建的问题:Qt qml别名问题
import QtQuick 2.7
import QtQuick.Controls 2.1
ApplicationWindow
{
id:mainscreen
property alias text2_alias: text2.text
visible: true
width: 640
height: 480
Rectangle
{
id:rec1
y:0
height: 40
width:300
border.color: "blue"
Text {
id: text1
text: "aaaa"
text2_alias:"cccc" // <<<<<<<<<<<<< Error red underline !!!
}
}
Rectangle
{
id:rec2
width:300
height: 40
anchors.top: rec1.bottom
border.color: "blue"
Text {
id: text2
text: "bbbbb"
}
}
}
的错误是:不能分配给不存在的财产“text2_alias” 我在哪里错了?
非常感谢。
'Text'没有名为'text2_alias'的属性。阅读[this](http://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html#property-aliases)页面以获取有关属性别名的更多信息。 – folibis
你预计会发生什么? – derM
你想在这里做什么? – dtech