下拉样式
//未下拉时,QComboBox 样式 背景黑色
QComboBox {
border:none;
color:#ffffff;
font-size:16px;
background: #000000;
border: 1px solid #2f445c;
}
//下拉箭头区域样式
QComboBox::drop-down{
width: 60px;
height: 60px;
background: #2f445c;
}
//下拉箭头样式
QComboBox::down-arrow {
image: url(:/images/maintain/combox.png);
height:20px;width:20px;
}
//下拉后的整个下拉窗体样式 背景红色
QComboBox QAbstractItemView{
color:#ffffff;
font-size:16px;
background: #000000;padding-left:
}
//下拉项样式 背景蓝色
QListView::item{padding-left:30px;background:0000ff;color:#ffffff;}
//下拉项选中样式(效果不明显)背景绿色
QListView::item:selected{
color:#DCDCDC;
background:#00ff00;
}
//下拉项鼠标悬浮样式 背景灰绿色
QListView::item:hover{
color:#DCDCDC;
background:#3da79d;
}
//未下拉时 设置居中显示
QLineEdit lineEdit = new QLineEdit;
lineEdit->setReadOnly(true);
lineEdit->setAlignment(Qt::AlignCenter);
lineEdit->setStyleSheet(“border:none;color:#ffffff;font-size: 24px;background: #000000;”);
ui->comboBox->setLineEdit(lineEdit);
//下拉项 设置居中显示和高度设置
QComboBox QAbstractItemView::item { height: 40px; }
ui->comboBox->setView(new QListView());
for(int i = 0; i < ui->comboBox->count(); i++)
{
static_cast<QStandardItemModel>(ui->comboBox->view()->model())->item(i)->setTextAlignment(Qt::AlignCenter);
}