QML类型

类型名

描述

实例

action

具有 QAction类型的所有属性:

Ø  slot action.trigger

Ø  bool action.enabled

Ø  string action.text

MouseArea { onClicked: myaction.trigger() }

 State { name: "enabled"; when: myaction.enabled == true }

 Text { text: someaction.text }

bool

true/false

Item { focus: true; clip: false }

color

三种赋值方式:

Ø  SVG颜色名称(参见附录);

Ø  直接使用RGB值;

Ø  使用QT函数;

Qt.rgba(), Qt.hsla(), Qt.darker(), Qt.lighter() or Qt.tint()

Rectangle { color: "steelblue" }

 Rectangle { color: "#FF0000" }

 Rectangle { color: "#800000FF" }  // 透明

Rectangle { color: Qt.rgba(255, 0, 0, 1) }

date

赋值方式:

Ø  YYYY-MM-DD格式字符串

MyDatePicker {

minDate: "2000-01-01";

maxDate: "2020-12-31" }

enumeration

复制方式:

Ø  <Element>.<value>

Text { horizontalAlignment: Text.AlignRight }

font

具有QFont类型的所有属性:

Ø  string font.family

Ø  bool font.bold

Ø  bool font.italic

Ø  bool font.underline

Ø  real font.pointSize

Ø  int font.pixelSize

Text {

 font.family: "Helvetica";

font.pointSize: 13;

font.bold: true }

int

整形数字

Item { width: 100; height: 200 }

list

 

Item {

     children: [

         Item { id: child1 },

         Rectangle { id: child2 },

         Text { id: child3 }

     ]

 }

child1, child2 and child3三个对象将按照顺序添加到children list中;

point

具有xy属性;

两种赋值方式:

Ø  “x,y”字符串

Ø  使用QT函数

Qt.point

CustomObject { myPointProperty: "0,20" }

CustomObject { myPointProperty: Qt.point(0, 20) }

real

小数

Item { width: 100.45; height: 150.82 }

rect

具有x, y, width, height属性;

两种赋值方式:

Ø  "x, y, width x height"字符串

Ø  使用QT函数

Qt.rect()

CustomObject { myRectProperty: "50,50,100x100" }

CustomObject { myRectProperty: Qt.rect(50, 50, 100, 100) }

size

具有width, height属性;

两种赋值方式:

Ø  "width x height"字符串

Ø  使用QT函数

Qt.size()

LayoutItem { preferredSize: "150x50" }

LayoutItem { preferredSize: Qt.size(150, 50) }

string

字符串,具有length属性;

Text { text: "Hello world!" }

time

赋值方式:

Ø  "hh:mm:ss"字符串

MyTimePicker { time: "14:22:15" }

url

超级链接:相对/绝对;

Image { source: "pics/logo.png" }

vector3d

三维向量,具有x, y, and z属性;

Ø  三种赋值方式:

Ø  "x,y,z" 字符串

Ø  使用QT函数

Qt.vector3d

Ø  单独赋值

 

Rotation { angle: 60; axis: "0,1,0" }

Rotation { angle: 60; axis: Qt.vector3d(0, 1, 0) }

Rotation { angle: 60; axis.x: 0; axis.y: 1; axis.z: 0 }

你可能感兴趣的:(Date,String,image,vector,action,qt)