kiss-o-matic
kiss-o-matic

Reputation: 1181

QStyleSheet over-riding general style

I'm trying to change the color of QComboBox (or a few widgets actually) but it seems that when I create a QStyleSheet with just a color property, it over writes all the other properties. Most notably on Windows, rounded QComboBoxes become square, and rather ugly. Snippet below (note that the colors in the actual code are generated. Just using black on white for ease).

QString styleSheet = "QComboBox { background-color: #ffffff; color: #000000 }";
combBox->setStyleSheet( styleSheet );

Sorry for the ridiculous sizing of these images.

This is a regular, non-styled QComboBox:

And this is a QComboBox after applying the aforementioned style:

Upvotes: 4

Views: 560

Answers (1)

Farhad
Farhad

Reputation: 4181

You are using Dynamic Stylesheets.

Reference: https://wiki.qt.io/Dynamic_Properties_and_Stylesheets

try using this in your code:

ui->comboBox->setStyleSheet("background-color: rgb(16, 72, 255); color: rgb(255, 17, 80);");

It's like append your stylesheet to the widget stylesheet.

Upvotes: 1

Related Questions