QComboBox drop-down item margin

Jacob Krieg picture Jacob Krieg · Aug 16, 2014 · Viewed 7.8k times · Source

I want to style my QComboBox with margin for the drop down items. This is how it looks like now:

enter image description here

And I would like something like this:

enter image description here

I tried with

QComboBox QAbstractItemView::item {
    margin: 3px;
}

but it doesn't work.

Can you help me with this?

Answer

Kosovan picture Kosovan · Aug 16, 2014

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}");

Result is very similar enter image description here