灰色的默认,选中是蓝色的,有圆角
代码中menu需要设置属性为Qt::FramelessWindowHint,否则会有黑框
QMenu *m_menu = new QMenu();
m_menu ->setWindowFlags(Qt::FramelessWindowHint);
QMenu
{
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 rgba(255, 255, 255, 240),
stop:0.2 rgba(255, 255, 255, 200),
stop:0.6 rgba(255, 255, 255, 160),
stop:1 rgba(255, 255, 255, 120));
qproperty-effect: blur(30px);
border-radius: 10px;
padding:4px 2px;
margin:4px 2px;
}
QMenu::item
{
background-color: transparent;
padding:2px 15px;
margin:2px 2px;
height: 30px; /* 设置item的高度 */
border-radius: 4px;
}
QMenu::item:selected
{
background-color: rgb(55,144,250);
}
/* 普通状态 */
QPushButton {
background-color: rgb(220,220,220);/* 设置背景颜色 */
border: 1px solid rgb(200,200,200); /* 设置边框 */
border-radius: 10px;
min-height: 25px;
color: #000000; /* 设置文字颜色 */
padding:4px 20px;
margin:4px 4px;
}
/* 鼠标悬停状态 */
QPushButton:hover {
background-color: rgb(55,144,250); /* 设置悬停时的背景颜色 */
color: #ffffff; /* 设置悬停时的文字颜色 */
}
/* 按下状态 */
QPushButton:pressed {
background-color: rgb(44,133,240); /* 设置按下时的背景颜色 */
color: #ffffff; /* 设置按下时的文字颜色 */
}
/* 复选框选中状态 */
QPushButton:checked {
background-color: rgb(55,144,250); /* 设置选中时的背景颜色 */
color: #ffffff; /* 设置选中时的文字颜色 */
}
/* 按钮被选中状态 */
QPushButton:pressed:checked {
background-color: rgb(44,133,240); /* 设置按钮被选中时的背景颜色 */
color: #ffffff; /* 设置按钮被选中时的文字颜色 */
}