View Full Version : Styling QComboBox and QSpinBox

18th December 2010, 15:42
I want to make the text (and only the text) gray and italic in a QComboBox and a QSpinBox. The QComboBox is not editable, and only the text in the "button" part (i.e. not in the drop-down) should be styled.

1. I try to set the text color of the QSpinBox using spin.setStyleSheet("QSpinBox {color:gray}") but under some styles (e.g. Oxygen on KDE4) the arrows in the QSpinBox are also changed. I try to counter this using spin.setStyleSheet("QSpinBox::up-arrrow {color:black}") but then I only get a gray box in place of the arrow. How can I prevent the color of the arrows from changing?

2. When styling a QComboBox using combo.setStyleSheet("QComboBox {color:gray; font-style:italic}") the items in the drop-down also become italic (although they remain black. How can I prevent any changes to the drop-down?