Style Combobox dropdown items with CSS

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
4 posts • Page 1 of 1
hbraun
Posts:15
Joined: Wed Aug 09, 2017 7:25 am

Style Combobox dropdown items with CSS

Post by hbraun »

Hello,

I cannot style items of the dropdown menu of a combobox. According to the documentation ("Creation of the CSS file") the dropdown menu and its items can be addressed with this way:

Code: Select all

QComboBox
{
  border: 1px solid black;
}
QComboBox QAbstractItemView
{
  margin: 10px;
}
QComboBox QAbstractItemView::item
{
  margin: 10px;
}
The 1px black border for the combobox and the 10px margin for the whole drop-down menu work but the margin for the single elements does not work. I also tried to set other properties like color of the single items but it seems the stylesheet does not have any effect.

Does anyone know if there are additional requirements for styling of the items?

3.16 P11 used.

Kind regards

uxout
Posts:82
Joined: Wed Jul 20, 2016 12:07 pm

Re: Style Combobox dropdown items with CSS

Post by uxout »

Have you tried to add background-color to property to the items ?

QComboBox QAbstractItemView::item
{
margin: 10px;
background-color: white;
}

Just tried on 3.16P12 and it works as you needed.

hbraun
Posts:15
Joined: Wed Aug 09, 2017 7:25 am

Re: Style Combobox dropdown items with CSS

Post by hbraun »

I tried using the backgournd-color but it does not work for me. I cannot style the items in the dropdown at all it seems (also background-color does not work).

Could you please send me a panel with a working example?

uxout
Posts:82
Joined: Wed Jul 20, 2016 12:07 pm

Re: Style Combobox dropdown items with CSS

Post by uxout »

Do you work on Editable Combobox?
If it is the case, that doesn't work as expected.
You might have the same problem as me with Edtable Combobox, try your stylesheet on non editable Combobox to check if it is ok or not.

4 posts • Page 1 of 1