QML中有许多可是控件,大家在QT的官方文档中可以找到:
这里只举了几个例子:
//导入模块
import QtQuick 2.6
import QtQuick.Window 2.2
//控件的导入模块
import QtQuick.Controls 2.0
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Column{
Button{
id: btn
text: '按钮'
}
Label{
text: 'Label'
color: 'red'
font.pointSize: 20
}
Rectangle {
width: 100
height: 100
color: "red"
border.color: "black"
border.width: 5
radius: 10
}
Slider{
from: 1
value: 25
to: 100
}
}
}
运行如下: