qt - 19种精美软件样式
qt - 19种精美软件样式
- 一、效果演示
- 二、核心程序
- 三、下载链接
一、效果演示


二、核心程序
#include "mainwindow.h"#include <QtAdvancedStylesheet.h>
#include <QmlStyleUrlInterceptor.h>#include "ui_mainwindow.h"
#include <QDir>
#include <QApplication>
#include <QAction>
#include <QListWidgetItem>
#include <QDockWidget>
#include <QVBoxLayout>
#include <QPushButton>
#include <QColorDialog>
#include <QDebug>
#include <QQmlEngine>#include <iostream>#define _STR(x) #x
#define STRINGIFY(x) _STR(x)/*** Private data class - pimpl*/
struct MainWindowPrivate
{CMainWindow* _this;Ui::MainWindow ui;acss::QtAdvancedStylesheet* AdvancedStyleSheet;QVector<QPushButton*> ThemeColorButtons;/*** Private data constructor*/MainWindowPrivate(CMainWindow* _public) : _this(_public) {}void createThemeColorDockWidget();void fillThemeMenu();void setSomeIcons();void setupQuickWidget();void updateThemeColorButtons();void updateQuickWidget();/*** Loads theme aware icons for the actions in the toolbar*/void loadThemeAwareToolbarActionIcons();
};void MainWindowPrivate::createThemeColorDockWidget()
{QDockWidget* dock = new QDockWidget(("Change Theme"), _this);QWidget* w = new QWidget(dock);auto Layout = new QVBoxLayout(w);Layout->setContentsMargins(12, 12, 12, 12);Layout->setSpacing(12);w->setLayout(Layout);dock->setWidget(w);_this->addDockWidget(Qt::LeftDockWidgetArea, dock);dock->setFloating(true);const auto& ThemeColors = AdvancedStyleSheet->themeColorVariables();for (auto itc = ThemeColors.constBegin(); itc != ThemeColors.constEnd(); ++itc){auto Button = new QPushButton(itc.key());QObject::connect(Button, &QPushButton::clicked, _this, &CMainWindow::onThemeColorButtonClicked);Layout->addWidget(Button);ThemeColorButtons.append(Button);}updateThemeColorButtons();
}void MainWindowPrivate::updateThemeColorButtons()
{for (auto Button : ThemeColorButtons){auto Color = AdvancedStyleSheet->themeColor(Button->text());QString TextColor = (Color.value() < 128) ? "#ffffff" : "#000000";QString ButtonStylesheet = QString("background-color: %1; color: %2;""border: none;").arg(Color.name()).arg(TextColor);Button->setStyleSheet(ButtonStylesheet);}
}void MainWindowPrivate::updateQuickWidget()
{const auto Source = ui.quickWidget->source();ui.quickWidget->setSource({});ui.quickWidget->engine()->clearComponentCache();ui.quickWidget->setSource(Source);ui.quickWidget->setStyleSheet(AdvancedStyleSheet->styleSheet());
}void MainWindowPrivate::fillThemeMenu()
{// Add actions for theme selectionauto m = ui.menuThemes;for (const auto& Theme : AdvancedStyleSheet->themes()){QAction* a = new QAction(Theme);m->addAction(a);QObject::connect(a, &QAction::triggered, _this, &CMainWindow::onThemeActionTriggered);}}void MainWindowPrivate::setSomeIcons()
{ui.actionToolbar->setIcon(AdvancedStyleSheet->styleIcon());QIcon Icon(":/full_features/images/logo_frame.svg");for (int i = 0; i < ui.listWidget_2->count(); ++i){ui.listWidget_2->item(i)->setIcon(Icon);}
}void MainWindowPrivate::setupQuickWidget()
{ui.quickWidget->engine()->setUrlInterceptor(new acss::CQmlStyleUrlInterceptor(AdvancedStyleSheet));ui.quickWidget->setStyleSheet(AdvancedStyleSheet->styleSheet());ui.quickWidget->setSource(QUrl("qrc:/full_features/qml/simple_demo.qml"));ui.quickWidget->setAttribute(Qt::WA_AlwaysStackOnTop);ui.quickWidget->setAttribute(Qt::WA_TranslucentBackground);ui.quickWidget->setClearColor(Qt::transparent);
}void MainWindowPrivate::loadThemeAwareToolbarActionIcons()
{ui.actionSelected->setIcon(AdvancedStyleSheet->loadThemeAwareSvgIcon(":/full_features/images/edit.svg"));ui.actionaction->setIcon(AdvancedStyleSheet->loadThemeAwareSvgIcon(":/full_features/images/folder_open.svg"));ui.actionaction2->setIcon(AdvancedStyleSheet->loadThemeAwareSvgIcon(":/full_features/images/save.svg"));ui.actionaction3->setIcon(AdvancedStyleSheet->loadThemeAwareSvgIcon(":/full_features/images/help_outline.svg"));
}CMainWindow::CMainWindow(QWidget *parent): QMainWindow(parent),d(new MainWindowPrivate(this))
{d->ui.setupUi(this);QString AppDir = qApp->applicationDirPath();QString StylesDir = STRINGIFY(STYLES_DIR);d->AdvancedStyleSheet = new acss::QtAdvancedStylesheet(this);d->AdvancedStyleSheet->setStylesDirPath(StylesDir);d->AdvancedStyleSheet->setOutputDirPath(AppDir + "/output");d->AdvancedStyleSheet->setCurrentStyle("qt_material");d->AdvancedStyleSheet->setDefaultTheme();d->AdvancedStyleSheet->updateStylesheet();setWindowIcon(d->AdvancedStyleSheet->styleIcon());qApp->setStyleSheet(d->AdvancedStyleSheet->styleSheet());connect(d->AdvancedStyleSheet, SIGNAL(stylesheetChanged()), this,SLOT(onStyleManagerStylesheetChanged()));d->createThemeColorDockWidget();d->fillThemeMenu();d->setSomeIcons();d->setupQuickWidget();d->loadThemeAwareToolbarActionIcons();
}CMainWindow::~CMainWindow()
{delete d;
}void CMainWindow::onThemeActionTriggered()
{auto Action = qobject_cast<QAction*>(sender());d->AdvancedStyleSheet->setCurrentTheme(Action->text());d->AdvancedStyleSheet->updateStylesheet();
}void CMainWindow::onStyleManagerStylesheetChanged()
{qApp->setStyleSheet(d->AdvancedStyleSheet->styleSheet());d->updateThemeColorButtons();d->updateQuickWidget();
}void CMainWindow::onThemeColorButtonClicked()
{auto Button = qobject_cast<QPushButton*>(sender());QColorDialog ColorDialog;auto Color = d->AdvancedStyleSheet->themeColor(Button->text());ColorDialog.setCurrentColor(Color);if (ColorDialog.exec() != QDialog::Accepted){return;}Color = ColorDialog.currentColor();d->AdvancedStyleSheet->setThemeVariableValue(Button->text(), Color.name());d->AdvancedStyleSheet->updateStylesheet();
}
三、下载链接
https://download.csdn.net/download/u013083044/88856325
相关文章:
qt - 19种精美软件样式
qt - 19种精美软件样式 一、效果演示二、核心程序三、下载链接 一、效果演示 二、核心程序 #include "mainwindow.h"#include <QtAdvancedStylesheet.h> #include <QmlStyleUrlInterceptor.h>#include "ui_mainwindow.h" #include <QDir&g…...
vue 使用docx库生成word表格文档
在Vue.js中生成Word表格文档,可以通过前端库来实现。这些库可以帮助我们轻松地将HTML表格转换为Word文档(通常是.docx格式)。以下是一些流行的前端库,它们可以用于在Vue项目中生成Word表格文档: docx…...
ElementUI table表格组件实现双击编辑单元格失去焦点还原,支持多单元格
在使用ElementUI table表格组件时有时需要双击单元格显示编辑状态,失去焦点时还原表格显示。 实现思路: 在数据中增加isFocus:false.控制是否显示在table中用cell-dblclick双击方法 先看效果: 上源码:在表格模板中用scope.row…...
Java基于SpringBoot+Vue的图书管理系统
博主介绍:✌程序员徐师兄、7年大厂程序员经历。全网粉丝12w、csdn博客专家、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ 🍅文末获取源码联系🍅 👇🏻 精彩专栏推荐订阅👇…...
【云安全】Hypervisor与虚拟机
Hypervisor 也被称为虚拟机监视器(Virtual Machine Monitor,VMM),主要作用是让多个操作系统可以在同一台物理机上运行。 Type-1 Hypervisor 与 Typer-2 Hypervisor Type-1 Hypervisor 直接安装在物理服务器上,不依赖…...
JS文本加密方法探究
在前端开发中,有时候我们需要对敏感文本进行简单的加密,以提高安全性。本文将介绍一种基于 JavaScript 实现的文本加密方法,使用了 Base64、Unicode 和 ROT13 编码。 示例代码 function encodeText(text) {// Base64编码var base64Encoded …...
推荐彩虹知识付费商城免授权7.0源码
彩虹知识付费商城免授权7.0源码,最低配置环境 PHP7.2 1、上传源码到网站根目录,导入数据库文件:xydai.sql 2、修改数据库配置文件:/config.php 3、后台:/admin 账号:admin 密码:123456 4、前…...
【天衍系列 04】深入理解Flink的ElasticsearchSink组件:实时数据流如何无缝地流向Elasticsearch
文章目录 01 Elasticsearch Sink 基础概念02 Elasticsearch Sink 工作原理03 Elasticsearch Sink 核心组件04 Elasticsearch Sink 配置参数05 Elasticsearch Sink 依赖管理06 Elasticsearch Sink 初阶实战07 Elasticsearch Sink 进阶实战7.1 包结构 & 项目配置项目配置appl…...
一、ActiveMQ介绍
ActiveMQ介绍 一、JMS1.jms介绍2.jms消息传递模式3.JMS编码总体架构 二、消息中间件三、ActiveMQ介绍1.引入的原因1.1 原因1.2 遇到的问题1.3 解决思路 2.定义3.特点3.1 异步处理3.2 应用系统之间解耦3.3 实际-整体架构 4.作用 一、JMS 1.jms介绍 jms是java消息服务接口规范&…...
【牛客】寒假训练营1 I-It‘s bertrand paradox. Again! 题解
传送门:It’s bertrand paradox. Again! 标签:随机 题目大意 有两个人分别用两种方式在二维平面上随机生成1e5个圆,每个圆上的每一个点(x,y)都满足-100<x<100且-100<y<100,现在将某个人生成的1e5个圆的圆心和半径告…...
各种手型都合适,功能高度可定制,雷柏VT9PRO mini和VT9PRO游戏鼠标上手
去年雷柏推出了一系列支持4KHz回报率的鼠标,有着非常敏捷的反应速度,在游戏中操作体验十分出色。尤其是这系列4K鼠标不仅型号丰富,而且对玩家的操作习惯、手型适应也很好,像是VT9系列就主打轻巧,还有专门针对小手用户的…...
sql建库,建表基础操作
当涉及到SQL建库和建表操作时,以下是一个简单的示例: 1. 建库(创建数据库) sql复制代码 CREATE DATABASE mydatabase; 上述语句将创建一个名为mydatabase的数据库。 2. 选择数据库 在创建表之前,需要选择要在其中…...
算法训练营day32,贪心算法6
import "strconv" //738. 单调递增的数字 func monotoneIncreasingDigits(n int) int { str : strconv.Itoa(n) nums : []byte(str) length : len(nums) if length < 1 { return n } for i : length - 1; i > 0; i-- { //如果前一个数字比当前值大࿰…...
CTR之行为序列建模用户兴趣:DIN
在前面的文章中,已经介绍了很多关于推荐系统中CTR预估的相关技术,今天这篇文章也是延续这个主题。但不同的,重点是关于用户行为序列建模,阿里出品。 概要 论文:Deep Interest Network for Click-Through Rate Predict…...
Java使用Redis实现分页功能
分页功能实现应该是比较常见的,对于redis来说,近期刷题就发现了lrange、zrange这些指令,这个指令怎么使用呢? 我们接下来就来讲解下。 目录 指令简介lrangezrange Java实现Redis实现分页功能 指令简介 lrange lrange 是 Redis 中…...
Qt标准对话框设置
Qt标准对话框设置,设置字体、调色板、进度条等。 #include "mainwindow.h" #include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow) {ui->setupUi(this); }MainWindow::~MainWi…...
如何让Obsidian实现电脑端和安卓端同步
Obsidian是一款知名的笔记软件,支持Markdown语法,它允许用户在多个设备之间同步文件。要在安卓设备上实现同步,可以使用remote save插件,以下是具体操作步骤: 首先是安装电脑端的obsidian,然后依次下载obs…...
windows系统中jenkins构建报错提示“拒绝访问”
一.背景 之前徒弟在windows中安装的jenkins,运行的时候用的是java -jar jenkins.war来运行的。服务器只有1个盘符C盘。今天说构建错误了,问我修改了啥,我年前是修改过构建思路的。 二.问题分析 先看jenkins构建任务的日志,大概是xcopy命令执…...
服务器防火墙的应用技术有哪些?
随着互联网的发展,网络安全问题更加严峻。服务器防火墙技术作为一种基础的网络安全技术,对于保障我们的网络安全至关重要。本文将介绍服务器防火墙的概念和作用,以及主要的服务器防火墙技术,包括数据包过滤、状态检测、代理服务、…...
力扣:40. 组合总和 II
回溯: 1.先声明好大集合和小集合,在调用回溯函数,终止条件为sumtarget,要进行剪枝操作减少遍历的次数,去重操作防止数组中有两个相同的值来组成的集合相同。 class Solution {List<List<Integer>> li1ne…...
【Java学习笔记】Arrays类
Arrays 类 1. 导入包:import java.util.Arrays 2. 常用方法一览表 方法描述Arrays.toString()返回数组的字符串形式Arrays.sort()排序(自然排序和定制排序)Arrays.binarySearch()通过二分搜索法进行查找(前提:数组是…...
vue3 定时器-定义全局方法 vue+ts
1.创建ts文件 路径:src/utils/timer.ts 完整代码: import { onUnmounted } from vuetype TimerCallback (...args: any[]) > voidexport function useGlobalTimer() {const timers: Map<number, NodeJS.Timeout> new Map()// 创建定时器con…...
ip子接口配置及删除
配置永久生效的子接口,2个IP 都可以登录你这一台服务器。重启不失效。 永久的 [应用] vi /etc/sysconfig/network-scripts/ifcfg-eth0修改文件内内容 TYPE"Ethernet" BOOTPROTO"none" NAME"eth0" DEVICE"eth0" ONBOOT&q…...
Python基于历史模拟方法实现投资组合风险管理的VaR与ES模型项目实战
说明:这是一个机器学习实战项目(附带数据代码文档),如需数据代码文档可以直接到文章最后关注获取。 1.项目背景 在金融市场日益复杂和波动加剧的背景下,风险管理成为金融机构和个人投资者关注的核心议题之一。VaR&…...
RabbitMQ入门4.1.0版本(基于java、SpringBoot操作)
RabbitMQ 一、RabbitMQ概述 RabbitMQ RabbitMQ最初由LShift和CohesiveFT于2007年开发,后来由Pivotal Software Inc.(现为VMware子公司)接管。RabbitMQ 是一个开源的消息代理和队列服务器,用 Erlang 语言编写。广泛应用于各种分布…...
通过MicroSip配置自己的freeswitch服务器进行调试记录
之前用docker安装的freeswitch的,启动是正常的, 但用下面的Microsip连接不上 主要原因有可能一下几个 1、通过下面命令可以看 [rootlocalhost default]# docker exec -it freeswitch fs_cli -x "sofia status profile internal"Name …...
C++实现分布式网络通信框架RPC(2)——rpc发布端
有了上篇文章的项目的基本知识的了解,现在我们就开始构建项目。 目录 一、构建工程目录 二、本地服务发布成RPC服务 2.1理解RPC发布 2.2实现 三、Mprpc框架的基础类设计 3.1框架的初始化类 MprpcApplication 代码实现 3.2读取配置文件类 MprpcConfig 代码实现…...
消防一体化安全管控平台:构建消防“一张图”和APP统一管理
在城市的某个角落,一场突如其来的火灾打破了平静。熊熊烈火迅速蔓延,滚滚浓烟弥漫开来,周围群众的生命财产安全受到严重威胁。就在这千钧一发之际,消防救援队伍迅速行动,而豪越科技消防一体化安全管控平台构建的消防“…...
【深度学习新浪潮】什么是credit assignment problem?
Credit Assignment Problem(信用分配问题) 是机器学习,尤其是强化学习(RL)中的核心挑战之一,指的是如何将最终的奖励或惩罚准确地分配给导致该结果的各个中间动作或决策。在序列决策任务中,智能体执行一系列动作后获得一个最终奖励,但每个动作对最终结果的贡献程度往往…...
云安全与网络安全:核心区别与协同作用解析
在数字化转型的浪潮中,云安全与网络安全作为信息安全的两大支柱,常被混淆但本质不同。本文将从概念、责任分工、技术手段、威胁类型等维度深入解析两者的差异,并探讨它们的协同作用。 一、核心区别 定义与范围 网络安全:聚焦于保…...
