QML 语法
QML结构 是基于 元素的层次结构.
每个子元素从 parent 继承位置.
Parent元素: Rectangle
Children元素: MouseArea 和 Text
chileren元素的x,y position继承自其parent元素,即x, y位置相同.
Properties
- 每个QML元素, 都有 很多元素属性(width, radius, font.pixelSize, border.width, model, delegate, etc)
- 定义 新属性: property <type> <name>: <value> Ex: property int count: 0
- QML中的类型有: var, int, real, string, bool, double, url, color, font, etc
- 声明属性的另一种方法是使用 别名alias. property alias <name>: <reference>
- alias别名属性 允许 forward 其它的属性或者object. Ex: property alias buttonText: textItem.text