标题:qml Row的parent不是item吗?TypeError: Result of expression 'parent' [null] is not an object.
作者:qiaofangjie
日期:2013-01-17 16:41
内容:
最近学习qml,在qt_quick中文手册上抄了一个例子FileMenu.qml,结果报错,不知道为什么?代码如下
FileMenu.qml:
import Qt 4.7
Row
{
anchors.centerIn: parent
spacing: parent.width/6
Button
{
id: loadButton
buttonColor: "lightgrey"
label: "Load"
}
Button
{
id: saveButton
buttonColor: "grey"
label: "Save"
}
Button
{
id: exitButton
buttonColor: "darkgrey"
label: "Exit"
onButtonClick: Qt.quit()
}
}Button.qml:
import Qt 4.7
Rectangle
{
border.width: 3
id:simplebutton
color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor
width: 150; height: 75
//radius: 10
property color buttonColor: "lightblue"
property color onHoverColor: "red"
property color borderColor: "white"
property string label: "button label"
signal buttonClick()
onButtonClick:
{
console.log(buttonLabel.text + " clic ..
#1 Re:qml Row的parent不是item吗?TypeError: Result of expression 'parent' [null] is not an&nbs [qiaofangjie 01-17 16:49]
执行qmlviewer FileMenu.qml 后,报错:FileMenu.qml:6: TypeError: Result of expression 'parent' is not an object.
请大家指教