QML基础知识
布尔值 true/false | |
double | 双精度数字类型 |
enumeration | 枚举 |
int | 整型 |
list | QML 对象列表 |
real | 实型(C++中 float) |
string | 字符串类型 |
url | 资源定位器 |
var | 通用属性类型 |
var:通用的属性,可以涉及任何数据类型,类似于c语言的void类型。
Item {
property var aNumber: 100
property var aBool: false
property var aString: "Hello world!"
property var anotherString: String("#FF008800")
property var aColor: Qt.rgba(0.2, 0.3, 0.4, 0.5)
property var aRect: Qt.rect(10, 10, 10, 10)
property var aPoint: Qt.point(10, 10)
property var aSize: Qt.size(10, 10)
property var aVector3d: Qt.vector3d(100, 100, 100)
property var anArray: [1, 2, 3, "four", "five", (function() { return "six"; })]
property var anObject: { "foo": 10, "bar": 20 }
property var aFunction: (function() { return "one"; })
}
font:字体属性
string font.family // 字体的名字,字体类型
bool font.bold // 是否使用粗体
bool font.italic // 是否使用斜体
bool font.underline // 是否使用下划线
real font.pointSize // 设定字体大小 (1pt = 0.3527mm)
int font.pixelSize // 设定字体大小, 当 pointSize 和 pixelSize 都设定了,那么使用pixelSize
enumeration font.weight // 设置文本的粗细 (可以选择的范围是0-99)
bool font.overline // 设置文字上方是否划线
bool font.strikeout // 设置文字是否使用strikeout 风格
enumeration font.capitalization // 设定文字的大小写属性,(如果有大小写之分的话)
real font.letterSpacing // 修改默认的字符间隔,可以是负数,如果是负数减少间隔
real font.wordSpacing //修改默认的词间隔,可以是负数,如果是负数减少间隔
font.MixedCase - 按照正常显示,不修改大小写
font.AllUppercase - 所有都大写
font.AllLowercase - 所有都小写
font.SmallCaps - 修改首字母为小写
font.Capitalize - 修改首字母为大写
color:设置颜色属性,颜色的设置有3种方式
Text {
color: "red" //设置为红色字体
}
Rectangle {
color: "#800000FF" // AARRGGBB fully transparent
y: 120; width: 40; height: 40
}
Rectangle {
color: "#FF0000" // RRGGBB fully transparent
}