PowerModeler/source/customMenu.cpp

47 lines
1.5 KiB
C++
Raw Normal View History

2025-03-14 16:06:20 +08:00
#include "customMenu.h"
#include <QGraphicsDropShadowEffect>
CustomMenu::CustomMenu(QWidget* parent)
:QMenu(parent)
{
2025-06-18 15:40:48 +08:00
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
//设置阴影
QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect(this);
shadow->setBlurRadius(12); //模糊半径
shadow->setOffset(4, 4); //偏移量
shadow->setColor(QColor(0, 0, 0, 200)); //阴影颜色
setGraphicsEffect(shadow);
2025-03-14 16:06:20 +08:00
//qss
setStyleSheet("QMenu{\n"
2025-06-18 15:40:48 +08:00
" margin:16px;\n"
2025-03-14 16:06:20 +08:00
" padding:2px;\n"
2025-06-11 09:36:42 +08:00
" color:rgb(240, 240, 240);\n"
2025-06-18 15:40:48 +08:00
" background-color:rgb(45, 45, 45);\n"
" border:1px solid rgb(0, 0, 0);\n"
2025-03-14 16:06:20 +08:00
"}\n"
"QMenu:item{\n"
" height:21px;\n"
"}\n"
"QMenu:item:text{\n"
" padding-left:15px;\n"
" padding-right:15px;\n"
"}\n"
2025-06-11 09:36:42 +08:00
"QMenu:item:disabled{\n"
" color:rgb(140, 140, 140);\n"
"}\n"
"QMenu::separator{\n"
" height:1px;\n"
2025-06-18 15:40:48 +08:00
" background:rgb(10, 10, 10);\n"
2025-06-11 09:36:42 +08:00
" margin-left:1px;\n"
" margin-right:1px;\n"
"}\n"
2025-03-14 16:06:20 +08:00
"QMenu:item:selected{\n"
2025-06-11 09:36:42 +08:00
" background-color: rgba(49, 91, 125, 180);\n"
2025-03-14 16:06:20 +08:00
"}\n");
}
CustomMenu::~CustomMenu()
{
}