Solved Switching Styles at runtime?
-
Hi there..
I managed to switch the Style of my Application in the main.cpp, with
if(CurrentTheme == "dark"){ // Load the dark application style QFile styleFile(":/style/style/TGS_Dark.qss"); styleFile.open( QFile::ReadOnly ); // Apply the loaded stylesheet QString style( styleFile.readAll() ); a.setStyleSheet(style); }else{ // Set default fusion style QApplication::setStyle(QStyleFactory::create("Fusion")); }
Now, i want to change the Theme of the Window, when the MainWindow is opened, by having the User being able to Select a Theme from a ComboBox (currently holding the Items "dark" and "light")
I can change the Style to the dark theme with:
if(CurrentTheme == "dark"){ // Load the dark application style QFile styleFile(":/style/style/TGS_Dark.qss"); styleFile.open( QFile::ReadOnly ); // Apply the loaded stylesheet QString styledark( styleFile.readAll() ); qApp->setStyleSheet(styledark); }else{ // Set default fusion style ? }
But i can´t simply copy the Code for the fusion theme over here..
How can i switch back to fusion, like for the dark Style? -
@SGaist Not with my past method..
My current method involves a Change of the Palette of fusion, to get dark mode.. and simply switch palettes from lightPalette to darkPalette.
New problem following...
-
-
@SGaist Not with my past method..
My current method involves a Change of the Palette of fusion, to get dark mode.. and simply switch palettes from lightPalette to darkPalette.
New problem following...