import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.5
Window {
width: 640
height: 480
color: "white"
title: qsTr("My QML")
visible: true
//摁住就加载的进度条
DelayButton{
width: 150
height: 50
delay: 3000
onProgressChanged: {
//progress 0.0-1.0
console.log(progress)
}
}
//单选排它按钮
Column{
x:200
RadioButton{
checked: true
text: qsTr("First")
}
RadioButton{
checked: false
text: qsTr("Second")
}
RadioButton{
checked: false
text: qsTr("Third")
}
}
//开关排它按钮
ButtonGroup{
id:btngrp
exclusive: true
buttons: col.children
}
Column{
y:200
id: col
Switch{
autoExclusive: true
text: qsTr("Wi-Fi")
//镜像
LayoutMirroring.enabled: true
//打印值0-1.0
//与visualPosition相等或相加为1
onPositionChanged: {
console.log("onPositionChanged: ",position)
}
//绝对从左往右
onVisualPositionChanged: {
console.log("onVisualPositionChanged: ",visualPosition)
}
}
Switch{
autoExclusive: true
text: qsTr("Wi-Fi2")
}
}
//切页按钮
TabBar{
x:200
y:200
TabButton{
text: qsTr("A")
}
TabButton{
text: qsTr("B")
}
TabButton{
text: qsTr("C")
}
}
//圆角按钮(普通按钮加圆角属性)
RoundButton{
x:300
text: "\u2713"
onClicked: TextArea.readOnly=true
}
//左右组合按钮
ToolBar {
y:100
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()
}
}
}
}
QML-Button扩展
最新推荐文章于 2024-08-15 18:19:19 发布