我得到以下各項文字設爲Qml元素語法錯誤
file:///C:/Qt/5.4/mingw491_32/Design1.qml:9:1: Syntax error
Text {
^
這是我非常簡單的代碼,但我不能讓它在運行qmlviewer
import QtQuick 2.0
Rectangle {
id: page
width: 500; height: 200
color: "lightgray"
}
Text {
id: Text1
text: "Hello World!"
y: 30
anchors.horizontalCenter: page.horizontalCenter
font.pointSize: 24; font.bold: true
}
它與縮進沒有關係。這是因爲'Text'必須成爲'Rectangle'的_child_,QML文件只能有一個根對象。請更正您的答案的描述。 – cmannett85 2015-03-25 07:09:35