QT QML 界面设计教程8——图标(图片)标签样式

2024-06-22 10:12

本文主要是介绍QT QML 界面设计教程8——图标(图片)标签样式,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

MyIconLabel.qml

import QtQuick 2.14
//Item可以替换为Rectangle以设置背景色
Item{id: controlproperty alias source: _icon.sourceproperty alias imageWidth: _icon.widthproperty alias imageHeight:_icon.heightproperty alias text: _text.textproperty alias color: _text.colorproperty alias font: _text.fontproperty alias spacing: _row.spacingproperty alias controlImage: _iconproperty alias controlText: _textproperty alias controlRow: _rowimplicitWidth: ((_icon.source&&_text.implicitWidth)?_row.spacing:0)+_icon.implicitWidth+_text.implicitWidth+_row.leftPadding+_row.rightPaddingimplicitHeight: 30Row {id: _row//图标和文本居中并排的话可以anchors.centerIn: parentheight: parent.heightwidth: parent.widthspacing: 6padding: 0leftPadding: 6rightPadding: 6Image {id: _iconanchors{verticalCenter: parent.verticalCenter}}Text{id: _textwidth: control.width-_icon.width-_row.leftPadding-_row.rightPaddinganchors{verticalCenter: parent.verticalCenter}color: "black"renderType: Text.NativeRenderingverticalAlignment: Text.AlignVCenterhorizontalAlignment: Text.AlignHCenter//wrapMode: Text.NoWrapelide: Text.ElideRightfont{family: "SimSun"pixelSize: 40}}}
}

调用:

Template1.ToolButton {id: controlproperty color textColor: (control.down || control.checked || control.highlighted || control.hovered) ? "cyan" : "white"property color buttonColor: (control.down || control.checked) ? "lightgreen": "transparent"//color: control.visualFocus ? control.palette.highlight : control.palette.buttonTextimplicitWidth:60;implicitHeight:50;//width: 60//height: 50padding: 0leftPadding: 2rightPadding: 12spacing: 6//自定义的MyIconLabelcontentItem: MyIconLabel {text: control.textfont: control.fontcolor: control.textColorspacing: control.spacingsource: control.icon.source //图片资源路径imageWidth: 45imageHeight: 45}background: Rectangle {implicitHeight: 50implicitWidth: 60color: control.buttonColor}}MyToolButton{ text: ""; icon.source: "qrc:/image/report/report.png" ; ToolTip.visible: hovered;ToolTip.text: qsTr("删除")}

这篇关于QT QML 界面设计教程8——图标(图片)标签样式的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1083994

相关文章

JAVA读取MongoDB中的二进制图片并显示在页面上

1:Jsp页面: <td><img src="${ctx}/mongoImg/show"></td> 2:xml配置: <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001

Steam邮件推送内容有哪些?配置教程详解!

Steam邮件推送功能是否安全?如何个性化邮件推送内容? Steam作为全球最大的数字游戏分发平台之一,不仅提供了海量的游戏资源,还通过邮件推送为用户提供最新的游戏信息、促销活动和个性化推荐。AokSend将详细介绍Steam邮件推送的主要内容。 Steam邮件推送:促销优惠 每当平台举办大型促销活动,如夏季促销、冬季促销、黑色星期五等,用户都会收到邮件通知。这些邮件详细列出了打折游戏、

X-AnyLabeling使用教程

1.AI 模型自动分割标注使用教程 2.AI 模型自动目标检测标注使用教程

在服务器上浏览图片

@StarSky 2018-10-26 15:09 字数 15971 阅读 28 https://www.zybuluo.com/StarSky/note/1294871 来源 2018-09-27 线上服务器安装 imgcat Tool   2018-09-27 线上服务器安装 imgcat 0. 准备文件:iterm2_shell_integration.bash1. 在有权限

青龙面板2.9之Cdle傻妞机器人编译教程

看到有的朋友对傻妞机器人感兴趣,这里写一下傻妞机器人的编译教程。 第一步,这里以linux amd64为例,去官网下载安装go语言安装包: 第二步,输入下方指令 cd /usr/local && wget https://golang.google.cn/dl/go1.16.7.linux-amd64.tar.gz -O go1.16.7.linux-amd64.tar.gz

青龙面板部署通用教程,含服务器、路由器、X86等部署方法

1. 拉取镜像/更新镜像 docker pull whyour/qinglong:latest 2. 删除镜像 docker rmi whyour/qinglong:latest 3. 启动容器 普通服务器 docker run -dit \-v $PWD/ql/config:/ql/config \-v $PWD/ql/log:/ql/log \-v $PWD/ql/db:

宝塔面板部署青龙面板教程【简单易上手】

首先,你得有一台部署了宝塔面板的服务器(自己用本地电脑也可以)。 宝塔面板部署自行百度一下,很简单,这里就不走流程了,官网版本就可以,无需开心版。 首先,打开宝塔面板的软件商店,找到下图这个软件(Docker管理器)安装,青龙面板还是安装在docker里,这里依赖宝塔面板安装和管理docker。 安装完成后,进入SSH终端管理,输入代码安装青龙面板。ssh可以直接宝塔里操作,也可以安装ssh连接

vscode-创建vue3项目-修改暗黑主题-常见错误-element插件标签-用法涉及问题

文章目录 1.vscode创建运行编译vue3项目2.添加项目资源3.添加element-plus元素4.修改为暗黑主题4.1.在main.js主文件中引入暗黑样式4.2.添加自定义样式文件4.3.html页面html标签添加样式 5.常见错误5.1.未使用变量5.2.关闭typescript检查5.3.调试器支持5.4.允许未到达代码和未定义代码 6.element常用标签6.1.下拉列表

PS系统教程25

介绍软件 BR(bridge) PS 配套软件,方便素材整理、管理素材 作用:起到桥梁作用 注意:PS和BR尽量保持版本一致 下载和安装可通过CSDN社区搜索,有免费安装指导。 安装之后,我们打开照片只需双击照片,就自动在Ps软件中打开。 前提:电脑上有PS软件 三种预览格式 全屏预览 评星级 直接按数字键就可以 方向键可以更换图片 esc退出 幻灯片放

QT 中ListView和ListWidget有什么区别

ListView和ListWidget在Qt框架中都是用于显示列表数据的控件,但它们在使用方法和特性上存在一些明显的差异。以下是关于它们用法不一样的地方的详细分析: 数据管理方式: ListView:使用QAbstractItemModel数据模型来管理和显示列表数据。QAbstractItemModel是一个抽象类,允许开发者自定义数据模型以适应特定的数据结构和需求。这使得ListView在处