Solved remove applied stylesheet in Qt
-
Hi,
First of all thanks to everybody to maintain this forum and give such a helpful answers.
My question is, I applied different theme from qss files, but I want to set default qt style when default.qss file selected by user.
I made a one Theme folder and in this there are somany qss file as per theme like dark.qss, light.qss, blue.qss, etc. User can apply anyone theme, when user will start app all time theme will apply for app, now I want to give option default theme, when user will select this theme, user will get default Qt theme, means no stylesheet.
What is logic to set default stylesheet/no-stylesheet?
How can I remove applied stylesheet?
What things will be in default.qss file?Thanks in advance.
-
@Tejas-Virpariya AFAIK setting it to blank should work.
setStyleSheet(styleSheet()); or setStyleSheet("");
-
Thanks, but its not work...
I applied theme already with open application.. means I setStyleSheet in main.cpp,
I used to button like applyTheme and removeTheme.
in applyThemesetStyleSheet(xyz.qss);
in removeTheme
setStyleSheet("");
but nothing happen.
-
@Tejas-Virpariya How did you directly apply qss file ?
-
@p3c0
:) not directly, read .qss file line by line and make string and apply that string in setStyleSheet.QString path = QApplication::applicationDirPath() + "/Theme/" + "default.qss"; QFile data(path); QString style; if (data.open(QFile::ReadOnly)) { QTextStream styleIn(&data); style = styleIn.readAll(); data.close(); a.setStyleSheet(style); }
-
@Tejas-Virpariya It should work. Can you try the same with a minimal example and post the same here ?
-
@p3c0
yup, thanks... you are right, its work, but in my case I applied theme in main.cpp so in this case it cannot work. Thank again.