Reputation: 329
I want to be able to create an simple internal theming system for my program (by internal I mean I don't need to be able to load custom themes from user system... all themes will be embedded inside the program itself.)
I can think of some ways:
I'm not sure what is the best way to achieve what I'm after, that will be best at both performance and the code itself...
I know the first way will be heavy in performance side, to each time change the whole stylesheet and rerender the whole program. (I think at least)
the second option though, I'm not sure how it will work, I mean its any better then the first one?!
or there is any other better methods..?
Upvotes: 0
Views: 912
Reputation: 3893
you should create a .qss
file and add it in your .qrc
like you add your icons.
then write all your stylesheet there. you can have multiple Style.qss
files and these files are your themes and whenever you change it your theme will change.
Style.qss
File in your Resources(.qrc)main.cpp
Load the application style
QFile styleFile(":/style.qss");
styleFile.open(QFile::ReadOnly);
Apply the loaded stylesheet
QString style(styleFile.readAll());
a.setStyleSheet(style);
For more information :
https://github.com/GTRONICK/QSS
https://github.com/ColinDuquesnoy/QDarkStyleSheet
Upvotes: 1