原文
运行效果
3、运行
4、原理
属性anchors.horizontalCenter表示水平居中的位置,此处是页面中心
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表示水平居中的位置,此处是页面中心