http://qt-project.org/doc/qt-4.8/qml-tutorial.html
運行效果
步驟
1、創建QML文件(在QtCreator中根據嚮導創建或者直接用文本文件另存爲)
2、源碼(..\Examples\4.7\declarative\tutorials\helloworld)
import QtQuick 1.0
//![3]
//![1]
Rectangle {
id: page
width: 500; height: 200
color: "lightgray"
//![1]
//![2]
Text {
id: helloText
text: "Hello world!"
y: 30
anchors.horizontalCenter: page.horizontalCenter
font.pointSize: 24; font.bold: true
}
//![2]
}
3、運行
4、原理
- Import
- Rectangle
- Text
屬性anchors.horizontalCenter表示水平居中的位置,此處是頁面中心