我按照博主“我是唐”的文章(下面链接)修改了我的Qt的QMenu样式,增添了圆角,优化了阴影。
https://blog.csdn.net/qq_41673920/article/details/116980362
主要代码:
menu->setWindowFlags(menu->windowFlags() | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
menu->setAttribute(Qt::WA_TranslucentBackground);
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
shadow->setOffset(0, 0);
shadow->setColor(QColor("#444444"));
shadow->setBlurRadius(10);
menu->setGraphicsEffect(shadow);
做完后圆角和阴影都有了,但是却让QSS中QMenu::item:selected
失效了,
然后我注释掉最后一行(取消给QMenu添加阴影),又可以了,但是我又想要阴影
可我看博主中的动图演示是没有失效的,请问是怎么回事呢?
原作者效果: