Qt第六十六章:展示数据的标签

news2024/10/7 4:22:49

目录

一、效果图

二、qtDesigner

①拖出一个frame作为组容器并贴上背景样式

②拖出主要的三个控件:frame、line、frame、label*2

③固定大小并设置字体、布局一下

 ④拷贝三份并水平布局一下

⑤设置样式

⑥调整布局

三、ui文件

四、代码


 

一、效果图

二、qtDesigner

①拖出一个frame作为组容器并贴上背景样式

# 整体样式
QFrame#frame{
background-color: rgb(238, 242, 255);
border:2px solid rgb(255, 255, 255);
border-radius:15px;
}
②拖出主要的三个控件:frame、line、frame、label*2

③固定大小并设置字体、布局一下

# 标题字体
color: rgba(255, 255, 255,210);
padding-left:12px;
font: 700 italic 16pt "Segoe UI";

# 内容字体
color: rgb(255, 255, 255);
font: 17pt "Microsoft YaHei UI";
 ④拷贝三份并水平布局一下

⑤设置样式

 

# 标题一样式
QFrame#frame_2{
color: rgb(255, 255, 255);
border-radius: 15px;
background-color: qradialgradient(cx:0, cy:0, radius:1, fx:0.1, fy:0.1, stop:0 rgb(162, 129, 247),  stop:1 rgb(119, 111, 252));
border: 1px outset rgb(98, 91, 213);
}

# 标题二样式
QFrame#frame_5{
color: rgb(255, 255, 255);
border-radius: 15px;
background-color: qradialgradient(cx:0, cy:0, radius:1, fx:0.1, fy:0.1, stop:0 rgb(253, 139, 133),  stop:1 rgb(248, 194, 152));
border: 1px outset rgb(252, 194, 149)
}

# 标题三样式
QFrame#frame_16{
color: rgb(255, 255, 255);
border-radius: 15px;
background-color: qradialgradient(cx:0, cy:0, radius:1, fx:0.1, fy:0.1, stop:0 rgb(243, 175, 189),  stop:1 rgb(155, 118, 218));
border: 1px outset rgb(153, 117, 219)
}

# 标题四样式
QFrame#frame_19{
color: rgb(255, 255, 255);
border-radius: 15px;
background-color: qradialgradient(cx:0, cy:0, radius:1, fx:0.1, fy:0.1, stop:0 rgb(66, 226, 192),  stop:1 rgb(62, 154, 193));
border: 1px outset rgb(72, 158, 204)
}

 

⑥调整布局

 

三、ui文件

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>Form</class>
 <widget class="QWidget" name="Form">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>750</width>
    <height>295</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Form</string>
  </property>
  <layout class="QHBoxLayout" name="horizontalLayout_2">
   <item>
    <widget class="QFrame" name="frame">
     <property name="styleSheet">
      <string notr="true">QFrame#frame{
background-color: rgb(238, 242, 255);
border:2px solid rgb(255, 255, 255);
border-radius:15px;
}</string>
     </property>
     <property name="frameShape">
      <enum>QFrame::StyledPanel</enum>
     </property>
     <property name="frameShadow">
      <enum>QFrame::Raised</enum>
     </property>
     <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
       <widget class="QFrame" name="frame_2">
        <property name="minimumSize">
         <size>
          <width>160</width>
          <height>110</height>
         </size>
        </property>
        <property name="maximumSize">
         <size>
          <width>160</width>
          <height>110</height>
         </size>
        </property>
        <property name="styleSheet">
         <string notr="true">QFrame#frame_2{
color: rgb(255, 255, 255);
border-radius: 15px;
background-color: qradialgradient(cx:0, cy:0, radius:1, fx:0.1, fy:0.1, stop:0 rgb(162, 129, 247),  stop:1 rgb(119, 111, 252));
border: 1px outset rgb(98, 91, 213);
}</string>
        </property>
        <property name="frameShape">
         <enum>QFrame::StyledPanel</enum>
        </property>
        <property name="frameShadow">
         <enum>QFrame::Raised</enum>
        </property>
        <layout class="QVBoxLayout" name="verticalLayout">
         <item>
          <widget class="QFrame" name="frame_3">
           <property name="frameShape">
            <enum>QFrame::StyledPanel</enum>
           </property>
           <property name="frameShadow">
            <enum>QFrame::Raised</enum>
           </property>
           <layout class="QHBoxLayout" name="horizontalLayout_7">
            <item>
             <widget class="QLabel" name="label">
              <property name="styleSheet">
               <string notr="true">color: rgba(255, 255, 255,210);
padding-left:12px;
font: 700 italic 16pt &quot;Segoe UI&quot;;
</string>
              </property>
              <property name="text">
               <string>TextLabel</string>
              </property>
             </widget>
            </item>
           </layout>
          </widget>
         </item>
         <item>
          <widget class="Line" name="line">
           <property name="orientation">
            <enum>Qt::Horizontal</enum>
           </property>
          </widget>
         </item>
         <item>
          <widget class="QFrame" name="frame_4">
           <property name="frameShape">
            <enum>QFrame::StyledPanel</enum>
           </property>
           <property name="frameShadow">
            <enum>QFrame::Raised</enum>
           </property>
           <layout class="QHBoxLayout" name="horizontalLayout_8">
            <item>
             <widget class="QLabel" name="label_2">
              <property name="styleSheet">
               <string notr="true">color: rgb(255, 255, 255);
font: 17pt &quot;Microsoft YaHei UI&quot;;
</string>
              </property>
              <property name="text">
               <string>TextLabel</string>
              </property>
             </widget>
            </item>
           </layout>
          </widget>
         </item>
        </layout>
       </widget>
      </item>
      <item>
       <widget class="QFrame" name="frame_5">
        <property name="minimumSize">
         <size>
          <width>160</width>
          <height>110</height>
         </size>
        </property>
        <property name="maximumSize">
         <size>
          <width>160</width>
          <height>110</height>
         </size>
        </property>
        <property name="styleSheet">
         <string notr="true">QFrame#frame_5{
color: rgb(255, 255, 255);
border-radius: 15px;
background-color: qradialgradient(cx:0, cy:0, radius:1, fx:0.1, fy:0.1, stop:0 rgb(253, 139, 133),  stop:1 rgb(248, 194, 152));
border: 1px outset rgb(252, 194, 149)
}</string>
        </property>
        <property name="frameShape">
         <enum>QFrame::StyledPanel</enum>
        </property>
        <property name="frameShadow">
         <enum>QFrame::Raised</enum>
        </property>
        <layout class="QVBoxLayout" name="verticalLayout_6">
         <item>
          <widget class="QFrame" name="frame_10">
           <property name="frameShape">
            <enum>QFrame::StyledPanel</enum>
           </property>
           <property name="frameShadow">
            <enum>QFrame::Raised</enum>
           </property>
           <layout class="QHBoxLayout" name="horizontalLayout_9">
            <item>
             <widget class="QLabel" name="label_11">
              <property name="styleSheet">
               <string notr="true">color: rgba(255, 255, 255,210);
padding-left:12px;
font: 700 italic 16pt &quot;Segoe UI&quot;;
</string>
              </property>
              <property name="text">
               <string>TextLabel</string>
              </property>
             </widget>
            </item>
           </layout>
          </widget>
         </item>
         <item>
          <widget class="Line" name="line_6">
           <property name="orientation">
            <enum>Qt::Horizontal</enum>
           </property>
          </widget>
         </item>
         <item>
          <widget class="QFrame" name="frame_13">
           <property name="frameShape">
            <enum>QFrame::StyledPanel</enum>
           </property>
           <property name="frameShadow">
            <enum>QFrame::Raised</enum>
           </property>
           <layout class="QHBoxLayout" name="horizontalLayout_10">
            <item>
             <widget class="QLabel" name="label_12">
              <property name="styleSheet">
               <string notr="true">color: rgb(255, 255, 255);
font: 17pt &quot;Microsoft YaHei UI&quot;;
</string>
              </property>
              <property name="text">
               <string>TextLabel</string>
              </property>
             </widget>
            </item>
           </layout>
          </widget>
         </item>
        </layout>
       </widget>
      </item>
      <item>
       <widget class="QFrame" name="frame_16">
        <property name="minimumSize">
         <size>
          <width>160</width>
          <height>110</height>
         </size>
        </property>
        <property name="maximumSize">
         <size>
          <width>160</width>
          <height>110</height>
         </size>
        </property>
        <property name="styleSheet">
         <string notr="true">QFrame#frame_16{
color: rgb(255, 255, 255);
border-radius: 15px;
background-color: qradialgradient(cx:0, cy:0, radius:1, fx:0.1, fy:0.1, stop:0 rgb(243, 175, 189),  stop:1 rgb(155, 118, 218));
border: 1px outset rgb(153, 117, 219)
}</string>
        </property>
        <property name="frameShape">
         <enum>QFrame::StyledPanel</enum>
        </property>
        <property name="frameShadow">
         <enum>QFrame::Raised</enum>
        </property>
        <layout class="QVBoxLayout" name="verticalLayout_7">
         <item>
          <widget class="QFrame" name="frame_17">
           <property name="frameShape">
            <enum>QFrame::StyledPanel</enum>
           </property>
           <property name="frameShadow">
            <enum>QFrame::Raised</enum>
           </property>
           <layout class="QHBoxLayout" name="horizontalLayout_3">
            <item>
             <widget class="QLabel" name="label_13">
              <property name="styleSheet">
               <string notr="true">color: rgba(255, 255, 255,210);
padding-left:12px;
font: 700 italic 16pt &quot;Segoe UI&quot;;
</string>
              </property>
              <property name="text">
               <string>TextLabel</string>
              </property>
             </widget>
            </item>
           </layout>
          </widget>
         </item>
         <item>
          <widget class="Line" name="line_7">
           <property name="orientation">
            <enum>Qt::Horizontal</enum>
           </property>
          </widget>
         </item>
         <item>
          <widget class="QFrame" name="frame_18">
           <property name="frameShape">
            <enum>QFrame::StyledPanel</enum>
           </property>
           <property name="frameShadow">
            <enum>QFrame::Raised</enum>
           </property>
           <layout class="QHBoxLayout" name="horizontalLayout_4">
            <item>
             <widget class="QLabel" name="label_14">
              <property name="styleSheet">
               <string notr="true">color: rgb(255, 255, 255);
font: 17pt &quot;Microsoft YaHei UI&quot;;
</string>
              </property>
              <property name="text">
               <string>TextLabel</string>
              </property>
             </widget>
            </item>
           </layout>
          </widget>
         </item>
        </layout>
       </widget>
      </item>
      <item>
       <widget class="QFrame" name="frame_19">
        <property name="minimumSize">
         <size>
          <width>160</width>
          <height>110</height>
         </size>
        </property>
        <property name="maximumSize">
         <size>
          <width>160</width>
          <height>110</height>
         </size>
        </property>
        <property name="styleSheet">
         <string notr="true">QFrame#frame_19{
color: rgb(255, 255, 255);
border-radius: 15px;
background-color: qradialgradient(cx:0, cy:0, radius:1, fx:0.1, fy:0.1, stop:0 rgb(66, 226, 192),  stop:1 rgb(62, 154, 193));
border: 1px outset rgb(72, 158, 204)
}
</string>
        </property>
        <property name="frameShape">
         <enum>QFrame::StyledPanel</enum>
        </property>
        <property name="frameShadow">
         <enum>QFrame::Raised</enum>
        </property>
        <layout class="QVBoxLayout" name="verticalLayout_8">
         <item>
          <widget class="QFrame" name="frame_20">
           <property name="frameShape">
            <enum>QFrame::StyledPanel</enum>
           </property>
           <property name="frameShadow">
            <enum>QFrame::Raised</enum>
           </property>
           <layout class="QHBoxLayout" name="horizontalLayout_5">
            <item>
             <widget class="QLabel" name="label_15">
              <property name="styleSheet">
               <string notr="true">color: rgba(255, 255, 255,210);
padding-left:12px;
font: 700 italic 16pt &quot;Segoe UI&quot;;
</string>
              </property>
              <property name="text">
               <string>TextLabel</string>
              </property>
             </widget>
            </item>
           </layout>
          </widget>
         </item>
         <item>
          <widget class="Line" name="line_8">
           <property name="orientation">
            <enum>Qt::Horizontal</enum>
           </property>
          </widget>
         </item>
         <item>
          <widget class="QFrame" name="frame_21">
           <property name="frameShape">
            <enum>QFrame::StyledPanel</enum>
           </property>
           <property name="frameShadow">
            <enum>QFrame::Raised</enum>
           </property>
           <layout class="QHBoxLayout" name="horizontalLayout_6">
            <item>
             <widget class="QLabel" name="label_16">
              <property name="styleSheet">
               <string notr="true">color: rgb(255, 255, 255);
font: 17pt &quot;Microsoft YaHei UI&quot;;
</string>
              </property>
              <property name="text">
               <string>TextLabel</string>
              </property>
             </widget>
            </item>
           </layout>
          </widget>
         </item>
        </layout>
       </widget>
      </item>
     </layout>
    </widget>
   </item>
  </layout>
 </widget>
 <resources/>
 <connections/>
</ui>

四、代码

使用uic工具将ui文件转成py文件

import sys

from PySide6.QtGui import QColor
from PySide6.QtWidgets import *

from zzz.ui_home_3 import Ui_Form


# 继承UI类
class MainWindow(QWidget, Ui_Form):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.shadow_style(self.frame_2, QColor(162, 129, 247))
        self.shadow_style(self.frame_5, QColor(251, 157, 139))
        self.shadow_style(self.frame_16, QColor(170, 128, 213))
        self.shadow_style(self.frame_19, QColor(64, 186, 193))

    # 添加阴影
    def shadow_style(self, widget, Color):
        shadow = QGraphicsDropShadowEffect(self)
        shadow.setOffset(8, 8)  # offset
        shadow.setBlurRadius(38)  # shadow radius
        shadow.setColor(Color)  # shadow color
        widget.setGraphicsEffect(shadow)


if __name__ == '__main__':
    app = QApplication(sys.argv)

    window = MainWindow()
    window.show()

    sys.exit(app.exec())

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

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

相关文章

java蓝桥杯前10题总结

文章目录 1.单词分析1.代码2.知识点 2.成绩统计1.代码2.知识点1.如何四舍五入&#xff1f;2.如何保留小数点后几位小数呢&#xff1f; 3.最短路4.回文日期1.代码2.知识点1.日期类2.字符串细节3.连等的细节 5.门牌制作1.代码 6.卡片1.代码2.细节 7.数字三角形1.代码2.细节 8.成绩…

《向量数据库》——向量数据库MIlvus Cloud携手发起 AGI 黑客松,解锁行业更多可能

携手发起 AGI 黑客松,解锁行业更多可能 不止如此,双方在深度合作的基础上,还联合极客公园 Founder Park、智谱 AI 等,共同发起 AGI Playground Hackathon,旨在重新思考 AI Native 时代下的应用和服务,解决共同的行业发展问题。届时,Dify 将为参赛者提供接入了智谱 AI 模…

Domino中的源代码管理工具

大家好&#xff0c;才是真的好。 上次Notes/Domino 14 Drop2发布的时候&#xff0c;我们就提到&#xff0c;HCL一起发布了一款源代码管理工具。 这里还是简单科普一下&#xff0c;源代码管理工具&#xff0c;可以实现代码版本控制、备份&#xff0c;还有多个程序员之间的协作…

【ROOTFS】1-构建rootfs与nfs调试

简介 rootfs这一块比较简单&#xff0c;别怕&#xff0c;基本就是拿一个busybox过来&#xff0c;然后编译一下&#xff0c;就可以在指定的目录下生成一堆文件夹和文件&#xff0c;你可以把这个当成rootfs了&#xff1b; busybox: https://busybox.net/ 教程文档 【链接】 b…

绿盾控制台如何给未授权终端分配相应权限

环境&#xff1a; 绿盾控制台7.0 问题描述&#xff1a; 绿盾控制台如何给未授权终端分配相应权限 解决方案&#xff1a; 1.进入桌面管理系统 2.通过终端号&#xff0c;找到未授权终端下面&#xff0c;选择相应的未授权终端 3.点击鼠标右键&#xff0c;选择分配授权模块 4.下…

进阶课2——语音分类

语音分类主要是对语音从不同的维度进行识别和分类&#xff0c;这些维度可以包括语种、性别、年龄段、情绪、说话人身份等&#xff0c;具体如下&#xff1a; 语种分类&#xff1a;根据发音人的母语或者惯用语言&#xff0c;将语音分为不同的语种&#xff0c;例如中文、英文、法…

【UnityUGUI】UGUI六大组件和三大基本控件详解

&#x1f468;‍&#x1f4bb;个人主页&#xff1a;元宇宙-秩沅 &#x1f468;‍&#x1f4bb; hallo 欢迎 点赞&#x1f44d; 收藏⭐ 留言&#x1f4dd; 加关注✅! &#x1f468;‍&#x1f4bb; 本文由 秩沅 原创 &#x1f468;‍&#x1f4bb; 收录于专栏&#xff1a;UI_…

用ChatGPT编写Excel函数公式进行表格数据处理分析,so easy!

在用Excel进行数据处理分析时&#xff0c;经常需要编写不同的公式&#xff0c;需要了解大量的函数。有了ChatGPT&#xff0c;就很简单了&#xff0c;直接用自然语言描述自己的需求&#xff0c;然后让ChatGPT写出公式就好了。 例子1&#xff1a; Excel某个单元格的内容是&#…

【鸿蒙软件开发】ArkTS常见组件之单选框Radio和切换按钮Toggle

文章目录 前言一、Radio单选框1.1 创建单选框1.2 添加Radio事件1.3 场景示例二、切换按钮Toggle2.1 创建切换按钮2.2 创建有子组件的Toggle2.3 自定义样式selectedColor属性switchPointColor属性 2.4 添加事件2.5 示例代码 总结 前言 Radio是单选框组件&#xff0c;通常用于提…

【深入探究Java集合框架】从List到Map的完整指南

文章目录 &#x1f31f; Java集合框架&#x1f34a; Collection&#x1f389; List&#x1f389; Set&#x1f389; Map &#x1f34a; 集合的选择&#x1f389; 1. 有序并允许重复元素的集合 List&#x1f389; 2. 无序并且不允许重复元素的集合 Set&#x1f389; 3. 维护映射…

大语言模型(LLM)综述(一):大语言模型介绍

A Survey of Large Language Models 前言1. INTRODUCTION2. OVERVIEW2.1 大语言模型的背景2.2 GPT系列模型的技术演变 前言 随着人工智能和机器学习领域的迅速发展&#xff0c;语言模型已经从简单的词袋模型&#xff08;Bag-of-Words&#xff09;和N-gram模型演变为更为复杂和…

DVWA(一)

环境搭建 搭建DVWA Web渗透测试靶场_dvwa 白屏-CSDN博客 Brute Force&#xff08;暴力破解&#xff09; LOW 输入账号密码 burp suite拦截请求 请求发送至intruder attack type:选择cluster bomb,将用户名和密码Add添加 payload 1 添加用户名字典&#xff0c;payload 2 添…

网工实验手册:RSTP如何配置?

1. 实验目的 熟悉RSTP的应用场景掌握RSTP的配置方法 想要华为数通配套实验拓扑和配置笔记的朋友们点赞关注&#xff0c;评论区留下邮箱发给你! 2. 实验拓扑 实验拓扑如图所示&#xff1a; 图&#xff1a;RSTP的配置 3. 实验步骤 &#xff08;1&#xff09; …

计算机网络——计算机网络体系结构(3/4)-计算机网络体系结构分层思想举例

目录 发送请求报文 应用层构建HTTP请求报文 运输层添加TCP首部 网络层添加IP首部 数据链路层形成帧 物理层转化为比特流 路由器处理 服务器处理 发回响应报文 计算机网络体系结构分层思想举例 假设网络拓扑如下所示&#xff0c;主机属于网络N1&#xff0c;Web服务器属…

卫星结构。。。

• 下图介绍了现代卫星中常见的组件&#xff0c;它们被分为 卫星有效载荷 和 卫星总线 。 – 卫星有效载荷 包括任务专用设备&#xff0c;例如用于地球观测的高分辨率相机或用于电信的强大无线电硬件。 – 卫星总线 包括操作和维护卫星所需的所有组件。 • 它被设计为独立于有效…

CorelDRAW Graphics Suite2024完整版最新功能介绍

CorelDRAW平面设计软件通常也被叫做CDR&#xff0c;CDR广泛应用于排版印刷、矢量图形编辑及网页设计等领域。通过CorelDRAW体验极具个性的自由创作&#xff0c;大胆展现真我&#xff0c;交付出众的创意作品。CorelDRAW拥有矢量插图、页面布局、图片编辑和设计工具&#xff0c;无…

基于鱼鹰优化的BP神经网络(分类应用) - 附代码

基于鱼鹰优化的BP神经网络&#xff08;分类应用&#xff09; - 附代码 文章目录 基于鱼鹰优化的BP神经网络&#xff08;分类应用&#xff09; - 附代码1.鸢尾花iris数据介绍2.数据集整理3.鱼鹰优化BP神经网络3.1 BP神经网络参数设置3.2 鱼鹰算法应用 4.测试结果&#xff1a;5.M…

计算机组成原理 03 1.2.3 计算机的层次结构 编译程序 解释程序

文章目录 计算机系统的层次结构计算机层次结构之间的联系虚拟机和裸机编译型语言和解释型语言编译型语言和解释型语言的区别编译程序和解释程序的区别 如何理解编译/解释速度 和运行速度编译型语言和解释型语言的优劣编译 汇编 解释 编译程序和解释程序写题目的时候需要注意的点…

Java学习_day03_变量数据类型运算符

文章目录 变量定义声明赋值使用简化 数据类型基本数据类型整型浮点型布尔型字符型空型 引用数据类型数据类型转换自动类型转换强制类型转换 运算符算术运算符赋值运算符比较运算符逻辑运算符位运算符条件运算符一元运算符二元运算符三元运算符运算符优先级 变量 变量类似于数学…

毅速丨3D打印结合拓扑优化 让轻量化制造更容易

制造轻量化对于提高能源利用效率、提高产品性能和减少环境影响&#xff0c;推动制造业的绿色化、高质量发展具有重要的促进作用。 轻量化设计对许多领域都有着重要影响&#xff0c;尤其是那些需要降低能源消耗、提高运输效率或减少对环境影响的领域。如航空航天&#xff0c;轻量…