当前位置: 首页 > news >正文

企业不想做网站的原因广东网站seo策划

企业不想做网站的原因,广东网站seo策划,陕西宁德建设工程有限公司网站,做视频点播网站要多少带宽概述 在Qt中,可以使用样式表(StyleSheet)来自定义 QMenu 的外观,包括其子项(如菜单项QAction)的颜色。但是,这通常可以设置 QMenu 的整体样式,而不能单独设置某个子项的颜色。不过&…

概述

在Qt中,可以使用样式表(StyleSheet)来自定义 QMenu 的外观,包括其子项(如菜单项QAction)的颜色。但是,这通常可以设置 QMenu 的整体样式,而不能单独设置某个子项的颜色。不过,我们可以通过自定义的 QWidgetAction实现这一目标:

效果图

实现过程

  1. 创建一个继承自 QWidgetAction 的子类 ColorAction。
  2. 添加一个的 QWidget,在 QWidget 中添加一个 QLabel。
  3. 为这个 QLabel 设置样式表。
  4. 然后,将这个自定义的 QWidgetAction 添加到 QMenu 中。

关键代码

ColorAction 类

#pragma once#include <QWidgetAction>
#include <QWidget>
#include <QLabel>  
#include <QVBoxLayout>  
#include <QStyleOption>class ColorAction : public QWidgetAction
{Q_OBJECTpublic:ColorAction(const QString text, const int nMenuHeight, QObject *parent = nullptr);~ColorAction();private:QLabel *label;QWidget *widget;
};
#include "ColorAction.h"ColorAction::ColorAction(const QString text, const int nMenuHeight, QObject *parent /*= nullptr*/) : QWidgetAction(parent)
{// 创建一个QWidget作为容器,并设置布局  widget = new QWidget();QVBoxLayout *layout = new QVBoxLayout(widget);layout->setContentsMargins(0, 0, 0, 0);// 创建QLabel并设置文字颜色  label = new QLabel(text, widget);label->setFixedHeight(nMenuHeight);label->setFont(QFont(QString::fromLocal8Bit("微软雅黑"), 10.5));label->setStyleSheet("QLabel{ padding-left:16px; color: #ff5050;background-color: rgb(255, 255, 255);} QLabel:hover{ background-color: #e9f2ff;}");layout->addWidget(label);setDefaultWidget(widget);
}ColorAction::~ColorAction()
{
}

使用 QMenu 类

#include "QMenuColorDemo.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QMouseEvent>class QPoint;QMenuColorDemo::QMenuColorDemo(QWidget *parent): QWidget(parent)
{ui.setupUi(this);	this->setFixedSize(310,200);_menu = new QMenu;_menu->setFixedWidth(115);_menu->setFont(QFont(QString::fromLocal8Bit("微软雅黑"), 10.5));int nMenuHeight = 30;_menu->setStyleSheet(QString::fromLocal8Bit("QMenu{\background:white;\border:1px solid lightgray;\padding-top:10px;\padding-bottom:10px;\}\QMenu::item{\padding:0px 20px;\height:%1px;\}\QMenu::item:selected:enabled{\background:#e9f2ff;\color:black;\}\QMenu::item:selected:!enabled{\background:transparent;\}\QMenu::separator{\height:1px;\background:#e4e4e4;\margin:5px 0px 5px 0px;\}").arg(nMenuHeight));_viewAction = new QAction(QString::fromLocal8Bit("查看"), this);_refreshAction = new QAction(QString::fromLocal8Bit("刷新"), this);_delAction = new ColorAction(QString::fromLocal8Bit("删除"), nMenuHeight, this);_menu->addAction(_viewAction);_menu->addAction(_refreshAction);_menu->addSeparator();_menu->addAction(_delAction);_btn = new QPushButton(QString::fromLocal8Bit("彩色菜单"));connect(_btn,&QPushButton::clicked,this, [=](){QPoint p = cursor().pos();_menu->exec(p);});QHBoxLayout * hLayout = new QHBoxLayout;hLayout->addWidget(_btn);hLayout->addStretch();QVBoxLayout *vLayout = new QVBoxLayout;vLayout->addItem(hLayout);vLayout->addStretch();this->setLayout(vLayout);	
}void QMenuColorDemo::mousePressEvent(QMouseEvent *event)
{if (event->button() == Qt::RightButton ){QPoint p = cursor().pos();_menu->exec(p);}
}

源码下载

https://download.csdn.net/download/qiangzi4646/89754043

http://www.hkea.cn/news/423246/

相关文章:

  • 建站之星平台优化推广网站排名
  • wordpress 网盘 插件郑州seo外包阿亮
  • 怎样建设网站首页广告营销平台
  • wordpress调起淘宝app什么叫做seo
  • 嘉兴做网站优化的公司网站维护公司
  • css层叠样式会不会影响打开网站的速度百度免费下载安装百度
  • 网站模板制作流程nba交易最新消息汇总
  • 近的网站在线客服系统网络优化工程师前景如何
  • 网站制作职业google入口
  • 广州网站 制作信科便宜网络营销软文范例500
  • 网站建设公开课长沙网站推广和优化
  • 建设网站的需求分析俄罗斯搜索引擎yandex推广入口
  • 可以做英文纵横字谜的网站搜狗网站收录入口
  • web前端开发是不是做网站百家号关键词排名优化
  • 夸克看网站要钱吗电商网站seo优化
  • 自己做网站排版138ip查询网域名解析
  • 东莞做网站 南城石佳2023网站推广入口
  • 广东省省建设厅网站郴州网站建设网络推广平台
  • 校园网站推广方案怎么做应用商店优化
  • 巩义网站建设网络营销公司是做什么的
  • 做网站基本教程一站式营销平台
  • 杭州模板网站建设电脑培训网上培训班
  • 大连做网站不错的公司怎样把广告放到百度
  • 网站上面带官网字样怎么做的网站设计的流程
  • 有个网站是做视频相册的网球排名即时最新排名
  • 论坛网站备案流程图优化大师怎么提交作业
  • 织梦政府网站模板百度在线入口
  • 专业做婚纱摄影网站会员制营销
  • 网站内容丰富互动营销平台
  • 阿里巴巴logo高清图谷歌seo网站推广