QML 控件大全

  • QML Type
    • Container
    • DelayButton
    • Dial
    • DialogButtonBox
    • Dialog
    • Drawer
    • Menu
    • MenuBar
    • Overlay
    • PageIndicator
    • RangeSlider
    • ScrollView
    • SpinBox
    • StackView
    • SwipeView
    • Switch
    • TabBar
    • ToolBar
    • ToolSeparator
    • ToolTip
    • Tumbler

QML Type

本篇主要介绍QtQuick Controls 2,Qt Creator 5.10

1.Container

import QtQuick 2.10
import QtQuick.Window 2.10
import QtQuick.Controls 2.3ApplicationWindow{visible: true;width: 1280;height: 720;Row {anchors.fill: parent;TabBar {id: tabBarcurrentIndex: 0width: parent.width - addButton.width - btnDelete.widthTabButton { text: "TabButton" }}Component {id: tabButtonTabButton { text: "TabButton" }}Button {id: addButtontext: "+"flat: trueonClicked: {tabBar.addItem(tabButton.createObject(tabBar))console.log("added:", tabBar.itemAt(tabBar.count - 1))}}Button {id: btnDeletetext: "-"flat: trueonClicked: {tabBar.removeItem(tabBar.itemAt(tabBar.count-1));}}}}

2.DelayButton

import QtQuick 2.10
import QtQuick.Window 2.10
import QtQuick.Controls 2.3ApplicationWindow{visible: true;width: 1280;height: 720;Label{id: lbl;text: "未点击";font.bold: true;font.pixelSize: 28;anchors.centerIn: parent;}DelayButton{id: delayBtn;text: "PressAndHold";onActivated: {lbl.text = "已点击";}}}

3.Dial

import QtQuick 2.10
import QtQuick.Window 2.10
import QtQuick.Controls 2.3ApplicationWindow{visible: true;width: 1280;height: 720;Label{id: lbl;text: "0";font.bold: true;font.pixelSize: 28;anchors.centerIn: parent;}Dial {id: dial//Keys.onLeftPressed: {}snapMode: Dial.SnapAlways;stepSize: 0.1;onMoved: {lbl.text = value;}}Button{id: btnIncreasetext: "增加"anchors.left: dial.right;anchors.leftMargin: 40;anchors.bottom: dial.bottom;onClicked: {dial.increase();}}Button{id: btnDecreasetext: "减少"anchors.left: btnIncrease.right;anchors.leftMargin: 40;anchors.bottom: btnIncrease.bottom;onClicked: {dial.decrease();}}
}

4.DialogButtonBox

import QtQuick 2.10
import QtQuick.Window 2.10
import QtQuick.Controls 2.3ApplicationWindow{visible: true;width: 1280;height: 720;Row{DialogButtonBox {standardButtons: DialogButtonBox.Ok | DialogButtonBox.CancelonAccepted: console.log("Ok clicked")onRejected: console.log("Cancel clicked")}DialogButtonBox {Button {text: qsTr("Save")DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole}Button {text: qsTr("Close")DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole}}}}

5.Dialog

import QtQuick 2.10
import QtQuick.Window 2.10
import QtQuick.Controls 2.3ApplicationWindow{visible: true;width: 1280;height: 720;Dialog {id: dialogx:(parent.width-width)/2y:(parent.height-height)/2implicitWidth: 500;implicitHeight: 300;title: "Title"modal: true;standardButtons: Dialog.Ok | Dialog.CancelonAccepted: console.log("Ok clicked")onRejected: console.log("Cancel clicked")}Button{text: "open";onClicked: {dialog.open();}}}

6.Drawer

import QtQuick 2.10
import QtQuick.Window 2.10
import QtQuick.Controls 2.3ApplicationWindow{visible: true;width: 1280;height: 720;Drawer {id: drawerwidth: 0.4 * parent.widthheight: parent.heightdragMargin: parent.width * 0.1; //拉动开始生效的区域,最低为0,也就是0的位置拖动才有效}Label {id: contenttext: "Aa"font.pixelSize: 96anchors.fill: parentverticalAlignment: Label.AlignVCenterhorizontalAlignment: Label.AlignHCentertransform: Translate {x: drawer.position * content.width * 0.33}}}

7.Menu

import QtQuick 2.10
import QtQuick.Window 2.10
import QtQuick.Controls 2.3ApplicationWindow{visible: true;width: 1280;height: 720;Button {id: fileButtontext: "File"onClicked: menu.open()Menu {id: menuy: fileButton.heightAction { text: "Cut" }Action { text: "Copy" }Action { text: "Paste" }MenuSeparator { }Menu {title: "Find/Replace"Action { text: "Find Next" }Action { text: "Find Previous" }Action { text: "Replace" }}}}}

8.MenuBar

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3ApplicationWindow{visible: true;width: 1280;height: 720;//    Material.theme: Material.Light
//    Material.accent: Material.PurplemenuBar: MenuBar {Menu {title: qsTr("&File")Action { text: qsTr("&New...") }Action { text: qsTr("&Open...") }Action { text: qsTr("&Save") }Action { text: qsTr("Save &As...") }MenuSeparator { }Action { text: qsTr("&Quit") }}Menu {title: qsTr("&Edit")Action { text: qsTr("Cu&t") }Action { text: qsTr("&Copy") }Action { text: qsTr("&Paste") }}Menu {title: qsTr("&Help")Action { text: qsTr("&About") }}}}

9.Overlay

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3ApplicationWindow{visible: true;width: 1280;height: 720;Button {anchors.left: parent.left;anchors.leftMargin: 20;text: "Popup"onClicked: popup.open()Popup {id: popupparent: Overlay.overlayx: (parent.width - width) / 2y: (parent.height - height) / 2width: 500height: 300}}}

10.PageIndicator

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3ApplicationWindow{visible: true;width: 1280;height: 720;SwipeView {id: viewcurrentIndex: pageIndicator.currentIndexanchors.fill: parentPage {title: qsTr("Home")Label{anchors.centerIn: parenttext: "Home";font.bold: true;font.pixelSize: 28;}}Page {title: qsTr("Discover")Label{anchors.centerIn: parenttext: "Discover";font.bold: true;font.pixelSize: 28;}}Page {title: qsTr("Activity")Label{anchors.centerIn: parenttext: "Activity";font.bold: true;font.pixelSize: 28;}}}PageIndicator {id: pageIndicatorinteractive: truecount: view.countcurrentIndex: view.currentIndexanchors.bottom: parent.bottomanchors.horizontalCenter: parent.horizontalCenter}}

11.RangeSlider

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3ApplicationWindow{visible: true;width: 1280;height: 720;RangeSlider {id: rangeSliderfrom: 1to: 100first.value: 25second.value: 75first.onValueChanged:{}}Label{id: lbl;text: rangeSlider.first.value;anchors.centerIn: parent;}Label{text: rangeSlider.second.value;anchors.centerIn: parent;anchors.verticalCenterOffset: 30;}
}

12.ScrollView

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3ApplicationWindow{visible: true;width: 1280;height: 720;ScrollView {width: 200height: 200clip: trueLabel {text: "ABC"font.pixelSize: 224}}ScrollView {width: 200height: 200anchors.centerIn: parent;ListView {model: 20delegate: ItemDelegate {text: "Item " + index}}}
}

13.SpinBox

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3ApplicationWindow{visible: true;width: 1280;height: 720;SpinBox {id: spinboxfrom: 0value: 110to: 100 * 100stepSize: 100anchors.centerIn: parentproperty int decimals: 2property real realValue: value / 100//DoubleValidator 为随机数生成的,QIntValidatorvalidator: DoubleValidator {bottom: Math.min(spinbox.from, spinbox.to)top:  Math.max(spinbox.from, spinbox.to)}textFromValue: function(value, locale) {return Number(value / 100).toLocaleString(locale, 'f', spinbox.decimals)}valueFromText: function(text, locale) {return Number.fromLocaleString(locale, text) * 100}}
}

14.StackView

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3ApplicationWindow{visible: true;width: 1280;height: 720;StackView {id: stackinitialItem: mainViewanchors.fill: parent}Component {id: mainViewRow {spacing: 10Button {text: "Push"onClicked: stack.push(mainView)}Button {text: "Pop"enabled: stack.depth > 1onClicked: stack.pop()}Text {text: stack.depth}}}
}

15.SwipeView

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3ApplicationWindow{visible: true;width: 1280;height: 720;SwipeView {id: swipeViewanchors.fill: parent;Repeater {model: 6Loader {active: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItemsourceComponent: Text {text: index;Component.onCompleted: console.log("created:", index)Component.onDestruction: console.log("destroyed:", index)}}}}
}

16.Switch

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3ApplicationWindow{visible: true;width: 1280;height: 720;ColumnLayout {Switch {text: qsTr("Wi-Fi")}Switch {text: qsTr("Bluetooth")}}
}

17.TabBar

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3ApplicationWindow{visible: true;width: 1280;height: 720;TabBar {width: parent.widthTabButton {text: "First"//width: implicitWidth}TabButton {text: "Second"//width: implicitWidth}TabButton {text: "Third"//width: implicitWidth}}
}

18.ToolBar

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3ApplicationWindow{visible: true;width: 1280;height: 720;header: ToolBar {RowLayout {anchors.fill: parentToolButton {text: qsTr("‹")onClicked: stack.pop()}Label {text: "Title"elide: Label.ElideRighthorizontalAlignment: Qt.AlignHCenterverticalAlignment: Qt.AlignVCenterLayout.fillWidth: true}ToolButton {id: fileButton;text: qsTr("⋮")onClicked: menu.open()}}}Menu {id: menux: fileButton.x;y: fileButton.y;Action { text: "Cut" }Action { text: "Copy" }Action { text: "Paste" }MenuSeparator { }Menu {title: "Find/Replace"Action { text: "Find Next" }Action { text: "Find Previous" }Action { text: "Replace" }}}StackView {id: stackanchors.fill: parent}
}

19.ToolSeparator

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3ApplicationWindow{visible: true;width: 1280;height: 720;ToolBar {RowLayout {anchors.fill: parentToolButton {text: qsTr("Action 1")}ToolButton {text: qsTr("Action 2")}ToolSeparator {}ToolButton {text: qsTr("Action 3")}ToolButton {text: qsTr("Action 4")}ToolSeparator {}ToolButton {text: qsTr("Action 5")}ToolButton {text: qsTr("Action 6")}Item {Layout.fillWidth: true}}}
}

20.ToolTip

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3ApplicationWindow{visible: true;width: 1280;height: 720;Row{spacing: 30;Button {text: qsTr("Save")ToolTip.visible: downToolTip.text: qsTr("Save the active project")}Button {text: qsTr("Button")ToolTip.visible: pressedToolTip.delay: Qt.styleHints.mousePressAndHoldIntervalToolTip.text: qsTr("This tool tip is shown after pressing and holding the button down.")}Button {text: qsTr("Button")hoverEnabled: trueToolTip.delay: 1000ToolTip.timeout: 5000ToolTip.visible: hoveredToolTip.text: qsTr("This tool tip is shown after hovering the button for a second.")}Slider {id: slidervalue: 0.5ToolTip {parent: slider.handlevisible: slider.pressedtext: slider.value.toFixed(1)}}}
}

21.Tumbler

import QtQuick 2.10
import QtQuick.Controls.Material 2.3
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3ApplicationWindow{visible: true;width: 1280;height: 720;Rectangle {id: rect;width: frame.implicitWidth + 10height: frame.implicitHeight + 10function formatText(count, modelData) {var data = count === 12 ? modelData + 1 : modelData;return data.toString().length < 2 ? "0" + data : data;}FontMetrics {id: fontMetrics}Component {id: delegateComponentLabel {text: rect.formatText(Tumbler.tumbler.count, modelData)opacity: 1.0 - Math.abs(Tumbler.displacement) / (Tumbler.tumbler.visibleItemCount / 2)horizontalAlignment: Text.AlignHCenterverticalAlignment: Text.AlignVCenterfont.pixelSize: fontMetrics.font.pixelSize * 1.25}}Frame {id: framepadding: 0anchors.centerIn: parentRow {id: rowTumbler {id: hoursTumblermodel: 12delegate: delegateComponent}Tumbler {id: minutesTumblermodel: 60delegate: delegateComponent}Tumbler {id: amPmTumblermodel: ["AM", "PM"]delegate: delegateComponent}}}}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/536158.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Qt与QML的枚举绑定(C++枚举)

Qt到QML的枚举绑定 QML中是不支持c的枚举类型的&#xff0c;所以我们可以使用Qt的元对象系统&#xff0c;即MOS,来帮助我们实现。 进行绑定的好处就是&#xff0c;以后数据发生变化的时候&#xff0c;就是枚举发生增加修改&#xff0c;添加等的时候&#xff0c;不需要在QML中…

利用pyinstaller打包python3程序

pyInstaller是一款用于将pyhon程序打包成exe文件的工具&#xff0c;pyInstaller不是一个python的包&#xff0c; 只需要把pyInstaller的文件下载下来放到任意为止都可以&#xff0c;也就是说pyInstaller相当于独立出来专门干打包python的工具&#xff0c;这货是工具不是库&…

什么是递归函数?

文章目录递归函数递归例题特点效率优点递归函数 递归 递归就是一个函数在它的函数体内调用它自身。执行递归函数将反复调用其自身&#xff0c;每调用一次就进入新的一层。递归函数必须有结束条件。 当函数在一直递推&#xff0c;直到遇到墙后返回&#xff0c;这个墙就是结束条…

Angular的@Output与@Input理解

@Output与@Input理解 Output和Input是两个装饰器,是Angular2专门用来实现跨组件通讯,双向绑定等操作所用的。 @Input Component本身是一种支持 nest 的结构,Child和Parent之间,如果Parent需要把数据传输给child并在child自己的页面中显示,则需要在Child的对应 directiv…

腾讯云CDN配置

第一步&#xff1a;先去领取腾讯云CDN免费包23333333 以下为正式步骤&#xff1a; 在这里体现大家&#xff0c;域名一定要备案&#xff0c;另外要明白域名如何解析 前边问题不大&#xff0c;一切跟着腾讯云的套路来即可&#xff0c;需要注意的是网上后优化的配置大家可以自行…

Ubuntu中安装python3

通过命令行安装Python3.*&#xff0c;只需要在终端中通过命令行安装即可&#xff1a; sudo apt-get install python3 Ubuntu的底层大多数采用的是Python2.*&#xff0c;Python3和Python2是互相不兼容的&#xff0c;完全没法通用的&#xff08;也不知道他们怎么想的o(TヘTo)&a…

目标检测与分割总结

目标检测最常用的三个模型&#xff1a;Faster R-CNN、SSD和YOLO Faster R-CNN架构 在Faster RCNN中&#xff0c;候选框是经过RPN产生的&#xff0c;然后再把各个“候选框”映射到特征图上&#xff0c;得到RoIs。 Faster R-CNN步骤&#xff1a; (1) 由输入图片产生的区域候选…

win10连接烟台大学校园网

第一步 右键网络图标&#xff0c;打开网络管理中心 第二步&#xff1a; 设置添加新的网络&#xff0c;方法步骤如下&#xff1a; 第三步&#xff1a;新建VPN连接&#xff0c;注意协议为L2TP 第四步&#xff1a; 第五步&#xff1a; 第六步&#xff1a; 创建结束后进入更…

U-Net++粗略解释

Paper&#xff1a;UNet: A Nested U-Net Architecture for Medical Image Segmentation u-net网络的基本拓扑结构 目前最先进的图像分割模型是各种个同样的 encoder-decoder架构&#xff0c;他们具有一个关键的相似性&#xff1a;skip connections&#xff0c;它可以将编码器…

Docker+Nginx部署Angular

DockerNginx部署Angular 在部署Angular生产环境之前&#xff0c;需要电脑已经安装docker。 添加Dockerfile 在已经完成的Angular项目的项目根目录下添加Dockerfile文件。 Dockerfile文件内容&#xff1a; FROM nginx:1.11-1.11-alpine COPY index.html /usr/share/nginx/ht…

U-net网络详解

U-net网络 简单说一下网络图中各项所代表的内容&#xff1a; 蓝/白色框表示feature map(特征图) 蓝色箭头表示3x3卷积&#xff0c;主要用于特征提取 灰色箭头表示skip-connection&#xff08;跳跃连接&#xff0c;通常用于残差网络中&#xff09;,在这里是用于用于特征融合&…

SOLO算法简读

论文链接&#xff1a;https://arxiv.org/abs/1912.04488 代码链接&#xff1a;https://github.com/WXinlong/SOLO 摘要 提出一种新的实例分割方法。与语义分割等其他密集预测任务相比&#xff0c;实例分割的难度要大得多。为了预测每个实例的掩码&#xff0c;主流方法要么遵…

关于Loss的简单总结

Dice Loss 参考&#xff1a;https://blog.csdn.net/l7H9JA4/article/details/108162188 Dice系数&#xff1a; 是一种集合相似度度量函数&#xff0c;通常用于计算两个样本的相似度&#xff0c;取值范围为[0,1]。 s2∣X∩Y∣∣X∣∣Y∣s \frac{2|X ∩ Y|}{|X||Y|} s∣X∣∣Y…

SOLOv2论文简读

论文&#xff1a;SOLOv2: Dynamic, Faster and Stronger 代码&#xff1a;https://github.com/WXinlong/SOLO 摘要 主要提出了作者在SOLOv2中实现的优秀的实例分割方法&#xff0c;旨在创建一个简单、直接、快速的实例分割框架&#xff1a; 通过提出动态学习对象分割器的mas…

Ubuntu18.04 关于使用vnc的踩坑

由于种种原因&#xff0c;手上多了一台可使用的桌面版Ubuntu&#xff0c;正好用来测试代码&#xff0c;方便调试。因为只能远程&#xff0c;所以需要配置远程连接。因此就打算使用vnc进行远程连接&#xff0c;谁料一路坎坷&#xff0c;特此记录。 安装 设置桌面共享 需要注意…

App_Shell模型

App_Shell模型 App Shell 架构是构建 Progressive Web App 的一种方式,这种应用能可靠且即时地加载到您的用户屏幕上,与本机应用相似。 App shell是支持用户界面所需的最小的 HTML、CSS 和 JavaScript,如果离线缓存,可确保在用户重复访问时提供即时、可靠的良好性能。这意…

Jenkins自定义主题教程

Jenkins自定义主题 由于Jenkins自带的样式比较丑陋&#xff0c;所以有很多第三方的样式库&#xff0c;这里针对jenkins-material-theme样式库做一个安装教程。 下载样式库 下载连接 Select your color 选择一个你喜欢的主题颜色。Choose your company logo 上传你自定义的…

IndexedDB_Web 离线数据库

IndexedDB_Web 离线数据库 本文会从头剖析一下 IndexedDB 在前端里面的应用的发展。 indexedDB 目前在前端慢慢得到普及和应用。它正朝着前端离线数据库技术的步伐前进。以前一开始是 manifest、localStorage、cookie 再到 webSQL&#xff0c;现在 indexedDB 逐渐被各大浏览器认…

基于 Docker 的微服务架构

基于 Docker 的微服务架构-分布式企业级实践前言Microservice 和 Docker服务发现模式客户端发现模式Netflix-Eureka 服务端发现模式ConsulEtcdZookeeper 服务注册自注册模式 Self-registration pattern第三方注册模式 Third party registration pattern小结一 服务间的 IPC 机制…

funcode游戏实训,java及C/C++,网上整理

软件&#xff0c;常见错误都有。 所有资源可到公众号获取(源码也是)&#xff0c;不再直接分享