效果图
qss样式
QComboBox {background: #31355B; border:0;color: #FFFFFF;}
/*下拉框样式。selection-color 选中字体颜色;selection-background-color选中背景色;
outline:0px 去掉虚线框;margin-top 下拉列表与编辑框外边距*/
QComboBox QAbstractItemView{background:#4E5387;color:#FFFFFF;border:0;outline: 0px; selection-color:#FFC400;selection-background-color:#4E5387;margin-top:5px;}
/*下拉按钮样式*/
QComboBox::drop-down {width:20px; border:0;}
/*下拉箭头样式*/
QComboBox::down-arrow { width: 20px; image: url(:/Resources/icom_drop_down.svg);}
代码添加
设置下拉列表与编辑框外边距还需将QAbstractItemView的父窗口设置成透明的
comboBox->view()->window()->setAttribute(Qt::WA_TranslucentBackground);
去掉下拉框阴影
comboBox->view()->window()->setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);