PDA

View Full Version : Changing color of combobox placed in toolbar?



Jennie Bystrom
7th May 2010, 08:08
My application contains a toolbar with some buttons and a combobox. The combobox is editable but the lineEdit inside is read only so I change the background color to reflect this. When we were running qt4.3.2 I did this:




QLineEdit* lineEdit = cb->lineEdit();
QPalette palette = lineEdit->palette();
palette.setColor(QPalette::Base, QPalette.color(QPalette::Window));
lineEdit->setPalette(palette);



Where cb is the combobox placed in the toolbar. This worked fine and the cb changed color.

Now we have upgraded to qt4.6.1 and this solution doesn't work anymore. I can change the color of buttons and labels in the toolbar, but the color changes for the combobox is ignored. If I place a combobox somewhere else (eg not in the toolbar) the above code works fine.

We are using the motif style but this doesn't seem to work in any style as far as I can see.

So my question is how can I change the color for the combobox?