0
点赞
收藏
分享

微信扫一扫

QComboBox设置子项样式

倚然君 2022-08-17 阅读 69


ui->setupUi(this);
ui->comboBox->setFixedHeight(45);//子项高度
QPixmap pixmap(1, ui->comboBox->height());
pixmap.fill(Qt::transparent);
QIcon icon(pixmap);
ui->comboBox->setIconSize(QSize(1,ui->comboBox->height()));
ui->comboBox->addItem(icon,"程序");
ui->comboBox->addItem(icon,"图形");
ui->comboBox->addItem(icon,"数据");
ui->comboBox->addItem(icon,"网络");
ui->comboBox->move(10,10);
QStyledItemDelegate* itemDelegate = new QStyledItemDelegate();
ui->comboBox->setItemDelegate(itemDelegate);
ui->comboBox->view()->setFixedHeight(350);//设置下拉框总高度

qss::
QComboBox {
border: 1px solid green;
border-radius: 3px;
padding: 1px 2px 1px 2px;
min-width: 9em;
}
QComboBox::drop-down {
subcontrol-origin: padding;
subcontrol-position: top right;
border-left-width: 1px;
border-left-color: darkgray;
border-left-style: solid; /* just a single line */
border-top-right-radius: 3px; /* same radius as the QComboBox */
border-bottom-right-radius: 3px;
}



举报

相关推荐

0 条评论