DelayButton
属性
delay : int //延时时长,ms
progress : real //实时进度 0-1
信号
activated() //当按钮延时进度到达1,且选中按钮的情况激活该信号
实例
DelayButton
{
width: 150
height: 50
delay: 200
onProgressChanged:
{
console.log("progress: ", progress)
}
}
RadioButton
单选按钮,当多个单选按钮对象放到同一个父对象中,就会自动的实现排他性,不需要如勾选框那样放到一个Group中并设置exclusive或者设置单个按钮的排他属性autoExclusive
Column {
RadioButton {
checked: true
text: qsTr("First")
}
RadioButton {
text: qsTr("Second")
}
RadioButton {
text: qsTr("Third")
}
}
Switch
属性
position : real
visualPosition : real //mirred 镜像时才会有效
实例
ButtonGroup{
id: btngrp
exclusive: true
buttons: col.children
}
Column {
id: col
Switch {
LayoutMirroring.enabled: true
autoExclusive: true
text: qsTr("Wi-Fi")
onPositionChanged: {
console.log("pos: ", position)
}
onVisualPositionChanged: { //视觉上左到右的进度
console.log("visiblepos: ", visualPosition)
}
}
Switch {
autoExclusive: true
text: qsTr("Bluetooth")
}
}
TabButton
表格按钮,自带排他性,主要是用于切换页面使用。
TabBar {
TabButton {
text: qsTr("Home")
}
TabButton {
text: qsTr("Discover")
}
TabButton {
text: qsTr("Activity")
}
}
RoundButton
圆形按钮,继承与Button,增加radius属性
radius : real //边角弧度半径
RoundButton {
id:rbtn
text: "\u2713" // Unicode Character 'CHECK MARK'
onClicked: textArea.readOnly = true
radius: 10 //边角弧度半径
}
Button{
anchors.top: rbtn.bottom
width: rbtn.width
height: rbtn.height
background: Rectangle{
radius: 15
color: "red"
}
}
ToolButton
ToolBar {
Row {
anchors.fill: parent
ToolButton {
text: qsTr("‹")
onClicked: stack.pop()
}
Label {
text: "Title"
elide: Label.ElideRight
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
}
ToolButton {
text: qsTr("⋮")
onClicked: menu.open()
}
}
}
自定义按钮
Button{
id: control
width: 200
height: 60
padding: 0
text: "button"
// background:Rectangle{
// }
contentItem: Rectangle{ //对内容进行重绘
//默认背景色白色
// color: "transparent" //透明
color: "red"
opacity: 0.8
Text{
id: txt
text: control.text
font.pointSize: 20
color: "green"
}
Image {
id: img
source: "/2.jpg"
width: 50
height: 50
anchors.right: parent.right
}
}
}