I have my desktop QApplication (Qt 5.9) on which I successfully set a style using a stylesheet. At runtime every QWidget look correctly styled as intended.
What I need to know is the background-color of a specific styled widget, let's say a QTooltip.
I tried the QWidget::palette method but what I got looked like the system's default color for the QPalette::ColorRole I asked.
Moreover, qt docs recommend not to use this method when using stylesheets.
So... more generally, how can one query for a widget property defined via stylesheets?
You can't directly access individual properties of the style sheet. What you can do, is retrieve the style sheet and then you would need to parse it and find the property you are looking for (
some_widget->styleSheet()
would return it as aQString
).If you don't want to do that, and want to access the palette directly, you must use that instead of style sheet to change the colors.
Example code how you can style your code using palette instead of style sheet: