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上也有很好的实现
附件列表
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!