0

Before changing:

enter image description here

After changing parent widget styleSheet property to this:

background-color: rgb(5, 34, 78);

I see this:

enter image description here

QComboBox become really different. What happens? How to use regular QComboBox on dark background?

I am using Qt 5.5 without QML.

k06a
  • 17,755
  • 10
  • 70
  • 110
  • 2
    Setting stylesheet discards style. Try using [QPalette](http://doc.qt.io/qt-5.5/qpalette.html). – Amartel Jul 29 '15 at 07:03
  • @Amartel thanks, that work. Can you provide expanded description of happened problem so I will accept your answer? – k06a Jul 29 '15 at 07:09

2 Answers2

2

You have to set it to the main window only

yourWindow->setStyleSheet("{background-color: #HexNumber}");

or tell the QComboBox to not have style: yourWindow->setStyleSheet("QComboBox{background-color:none}");

or

yourWindow->setStyleSheet("QComboBox#ComboName{background-color:none}");

Megasa3
  • 766
  • 10
  • 25
1

According to manual:

When a style sheet is active, the QStyle returned by QWidget::style() is a wrapper "style sheet" style, not the platform-specific style. The wrapper style ensures that any active style sheet is respected and otherwise forwards the drawing operations to the underlying, platform-specific style (e.g., QWindowsXPStyle on Windows XP).

If all you want is to change some colors, leaving selected style unchanged, the better solution would be to use QPalette.

Amartel
  • 4,248
  • 2
  • 15
  • 21