Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QComboBox drop-down item margin

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?

like image 450
Jacob Krieg Avatar asked Nov 05 '25 21:11

Jacob Krieg


1 Answers

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

like image 137
Kosovan Avatar answered Nov 08 '25 16:11

Kosovan