QComboBox下拉列表项目的样式定义在QComboBox QAbstractItemView::item,比如编写如下一段css代码,定义下拉列表每一行的高度为25
QComboBox QAbstractItemView::item {
height: 25px;
}
运行程序后发现并不能生效,这时只需要给需要设置的QComboBox设置一个QStyledItemDelegate来替换掉默认的,自定义的样式表即可生效,用法如下:
QStyledItemDelegate* itemDelegate = new QStyledItemDelegate();
ui->comboBox->setItemDelegate(itemDelegate);