QComboBox 下拉项边距 [英] QComboBox drop-down item margin
本文介绍了QComboBox 下拉项边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想为我的 QComboBox
设置下拉项的边距.这是现在的样子:
I want to style my QComboBox
with margin for the drop down items. This is how it looks like now:
我想要这样的东西:
我试过
QComboBox QAbstractItemView::item {
margin: 3px;
}
但它不起作用.
你能帮我解决这个问题吗?
Can you help me with this?
推荐答案
你想在项目之间设置一些空间.我尝试了不同的样式表,但我无法得到结果.但我找到了这个解决方案.也许有帮助.
You want set some space between items.I try different stylesheets, but I can't get result. But I found this solution. Maybe it helps.
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}");
结果非常相似
这篇关于QComboBox 下拉项边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文