我想要为下拉项设置间距来美化我的
QComboBox
,现在的样子是这样的:
QComboBox QAbstractItemView::item {
margin: 3px;
}
但它无法工作。
你能帮我解决这个问题吗?
QComboBox
,现在的样子是这样的:
QComboBox QAbstractItemView::item {
margin: 3px;
}
但它无法工作。
你能帮我解决这个问题吗?
你想在项目之间设置一些空间。我尝试了不同的样式表,但是没有得到结果。但我找到了这个解决方案。也许它有所帮助。
ui->comboBox->setView(new QListView());
ui->comboBox->setStyleSheet("QComboBox QAbstractItemView::item { min-height: 35px; min-width: 50px; }QListView::item:selected { color: black; background-color: lightgray}");
结果非常相似
ui->comboBox->setItemDelegate(new QStyledItemDelegate());
同样适用