懒得去找原因了,直接将结果分享出来吧。
使用代理:
#include <QStyledItemDelegate>
private:
Ui::Widget *ui;
QStyledItemDelegate* itemDelegate;
itemDelegate = new QStyledItemDelegate();
ui->comboBox->setStyleSheet("QComboBox QAbstractItemView::item{height:30px;}" );
ui->comboBox->setItemDelegate(itemDelegate);
添加上面的代码就可以直接控制QComboBox的下拉框的高度了。当然ui->comboBox->setStyleSheet("QComboBox QAbstractItemView::item{height:30px;}" );
这行代码可以不要,在样式表里面添加也是可以的。