Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to change palette from QSS stylesheet
Kobid last edited by
I have this code:
QPalette p = qApp->palette();
Can I do this same but from QSS? I just want move this harcoded runtime style definition to the QSS so user can modify it. I googled how to read palette by paletterole but how to write?
AFAIK you can't. Palettes are "weaker" then QSS or native styling and are overridden by both of them. Therefore think of QSS as a replacement for palettes, not an interface to them.
But you can move palette settings to a file just as well as QSS. You can store the RGB values in whatever format - ini, json, xml or even something as trivial as
window 53 53 53 button 53 53 53 ...
and read them at runtime.