QTQuick控件基础(2)

import QtQuick 2. 2
import QtQuick.Controls 1. 2
import QtQuick.Window 2. 1

ApplicationWindow {
    visible : true
    width : 640
    height : 480
    title : qsTr( "Hello World")

    menuBar : MenuBar{
        Menu{
            title : qsTr( "File")
            MenuItem{
                text : qsTr( "EXIT")
                onTriggered : Qt.quit()
            }
        }
    }



    Column{
        spacing : 10
        //button
        Button{
            x : 10;y : 10;width : 140
            text :qsTr( "Button with menu")
            menu :Menu{
                MenuItem{text :qsTr( "Item1")}
                MenuItem{text :qsTr( "Item2")}
            }
        }
        //radiobutton
        ExclusiveGroup{id :group}
        RadioButton{
            text :qsTr( "from top")
            exclusiveGroup : group
            checked : true
        }
        RadioButton{
            text :qsTr( "from cursor")
            exclusiveGroup : group
        }
        //switch
        Switch{checked : true}
        Switch{checked : false}
        //combobox
        ComboBox{
            id :editableCombo
            editable : true
            model : ListModel{
                id :model
                ListElement{ text : "Banana";color : "Yellow"}
                ListElement{ text : "Apple";color : "Green"}
                ListElement{ text : "Cocont";color : "Brown"}
            }
            onAccepted : {
                if(editableCombo.find(currentText) == = - 1){
                    model.append({text :editText})
                    currentIndex = editableCombo.find(editText)
                }
            }
        }
        //spinbox
        SpinBox{
            minimumValue : - 5;maximumValue : 10
            prefix : "today";suffix : "degree"
            decimals : 1;stepSize : 1
        }
        //TextField
        TextField{
            width : 200
            placeholderText : "写字写字"
            echoMode : TextInput.PasswordEchoOnEdit
        }
        TextField{width : 200}
        //TextArea
        TextArea{
            width : 240
            textFormat : TextEdit.RichText
            font.pointSize : 13
            text : "<b>Hello</b><i>world!</i>"
        }
        TextArea{
            width : 240
            textFormat : TextEdit.PlainText
            font.pointSize : 13
            text : "<b>Hello</b><i>world!</i>"
        }
        //BusyIndicator
        BusyIndicator{
            running : true
        }
        //ProgressBar
        ProgressBar{
            id :progressBar
            minimumValue : 0
            maximumValue : 100
        }
        Timer{
            interval : 100
            running : true
            repeat : true
            onTriggered : progressBar.value ++
        }
    }


}

同样的道理,它在android上也有很好的实现







附件列表

     

    posted on   jsxyhelu  阅读(21)  评论(0编辑  收藏  举报

    相关博文:
    阅读排行:
    · 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
    · AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
    · 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
    · Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
    · 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!

    导航

    < 2025年3月 >
    23 24 25 26 27 28 1
    2 3 4 5 6 7 8
    9 10 11 12 13 14 15
    16 17 18 19 20 21 22
    23 24 25 26 27 28 29
    30 31 1 2 3 4 5

    统计

    点击右上角即可分享
    微信分享提示