QML 其他Button简介

1.DelayButton

一个可选中的按钮,当按住足够长时间时触发一个动作。

示例:按住按钮,进度增长。

Window {
    visible: true
    width: 400
    height: 400
    title: qsTr("Hello World")

    DelayButton{
        width: 100
        height: 50
        delay:2000
        onProgressChanged: {
            console.log("process = ",progress)
        }
    }
}

2.RadioButton

单选按钮,自动排他。

Window {
    visible: true
    width: 400
    height: 400
    title: qsTr("Hello World")

    ColumnLayout {
        RadioButton {
            checked: true
            text: qsTr("First")
        }
        RadioButton {
            text: qsTr("Second")
        }
        RadioButton {
            text: qsTr("Third")
        }
    }
}

3.Switch

开关按钮,可开启或关闭

Window {
    visible: true
    width: 400
    height: 400
    title: qsTr("Hello World")

    ColumnLayout {
        Switch {
            text: qsTr("Wi-Fi")
        }
        Switch {
            text: qsTr("Bluetooth")
        }
    }
}

4.TabButton

和TabBar一起使用

Window {
    visible: true
    width: 400
    height: 400
    title: qsTr("Hello World")

    TabBar {
        TabButton {
            text: qsTr("Home")
        }
        TabButton {
            text: qsTr("Discover")
        }
        TabButton {
            text: qsTr("Activity")
        }
    }
}

猜你喜欢

转载自blog.csdn.net/wzz953200463/article/details/129369965
QML
今日推荐