How to set different theme in the application created in QT.
-
I have created a application using QT and C++, in that particular application I want to have theme support, i.e. to have multiple theme in the application and it can be chosen by the user as per his/her connivance.
Is there an other approach then setting different CSS for each window.
using { Qt Creator 4.12.2
Based on Qt 5.14.2 (GCC 5.3.1 20160406 (Red Hat 5.3.1-6), 64 bit)
Built on Jun 2 2020 04:15:50 } -
I have created a application using QT and C++, in that particular application I want to have theme support, i.e. to have multiple theme in the application and it can be chosen by the user as per his/her connivance.
Is there an other approach then setting different CSS for each window.
using { Qt Creator 4.12.2
Based on Qt 5.14.2 (GCC 5.3.1 20160406 (Red Hat 5.3.1-6), 64 bit)
Built on Jun 2 2020 04:15:50 }QPalette
, other than that there is only stylesheet.Btw you can set one global stylesheet for your whole application, not only one for each widget/window.
qApp->setStylesheet(....);
-
@SGaist Thank you, have seen this but the issue is, some of my labels are used to show images and some of my labels are used to show the text, in which i want to have the theme set to only the label which has text not the image one, same way i have use many widgets in different way to overcome my application.
-
@SGaist Thank you, have seen this but the issue is, some of my labels are used to show images and some of my labels are used to show the text, in which i want to have the theme set to only the label which has text not the image one, same way i have use many widgets in different way to overcome my application.
@viraj1909 since it's your style you can apply the changes you want based on the rules you set. Hence, check if the label has text and only then apply your changes.
You can also create dedicate styles that you apply only to certain widgets.
In your case, maybe a QProxyStyle would be enough.