From d5d3cb15f06bc34d79cd1e356d0eca2950b50224 Mon Sep 17 00:00:00 2001 From: duanshengchao <519970194@qq.com> Date: Wed, 18 Jun 2025 15:40:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E8=8F=9C=E5=8D=95=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/customMenu.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/source/customMenu.cpp b/source/customMenu.cpp index 9068ed7..85c8290 100644 --- a/source/customMenu.cpp +++ b/source/customMenu.cpp @@ -4,13 +4,21 @@ CustomMenu::CustomMenu(QWidget* parent) :QMenu(parent) { + 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); //qss setStyleSheet("QMenu{\n" - " margin:2px;\n" + " margin:16px;\n" " padding:2px;\n" " color:rgb(240, 240, 240);\n" - " background-color:rgb(30, 30, 30);\n" - " border:1px solid rgb(50, 50, 50);\n" + " background-color:rgb(45, 45, 45);\n" + " border:1px solid rgb(0, 0, 0);\n" "}\n" "QMenu:item{\n" " height:21px;\n" @@ -24,19 +32,13 @@ CustomMenu::CustomMenu(QWidget* parent) "}\n" "QMenu::separator{\n" " height:1px;\n" - " background:rgb(140, 140, 140);\n" + " background:rgb(10, 10, 10);\n" " margin-left:1px;\n" " margin-right:1px;\n" "}\n" "QMenu:item:selected{\n" " background-color: rgba(49, 91, 125, 180);\n" "}\n"); - //设置阴影 - QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect(this); - shadow->setBlurRadius(20); //模糊半径 - //shadow->setOffset(15, 15); //偏移量 - shadow->setColor(QColor(0, 0, 0, 50)); //阴影颜色 - setGraphicsEffect(shadow); } CustomMenu::~CustomMenu()