After some research I found out, that Qt 5 now offers a so called Fusion theme which is desribed in one of their blog posts. I really like the theme with the black color configuration you can see in the last picture and I would like to use this in my application but it seems like this color scheme is forced by Unity/Gnome3 (looks like an Ubuntu window) so I am eager to knowing whether there is any available stylesheet or workaround to apply this dark version of the theme to an application.
3 Answers
I'm sure you already found it, but, as TheBootroo said, Fusion theme is controlled by the color palette.
I've found a recreation of the palette here. It isn't complete at all!
qApp->setStyle(QStyleFactory::create("Fusion"));
QPalette p = qApp->palette();
p.setColor(QPalette::Window, QColor(53,53,53));
p.setColor(QPalette::Button, QColor(53,53,53));
p.setColor(QPalette::Highlight, QColor(142,45,197));
p.setColor(QPalette::ButtonText, QColor(255,255,255));
p.setColor(QPalette::WindowText, QColor(255,255,255));
qApp->setPalette(p);
Edit: I've created a gist so we can make it feature-complete.
This is my dark palette:
// set style
qApp->setStyle(QStyleFactory::create("Fusion"));
// increase font size for better reading
QFont defaultFont = QApplication::font();
defaultFont.setPointSize(defaultFont.pointSize()+2);
qApp->setFont(defaultFont);
// modify palette to dark
QPalette darkPalette;
darkPalette.setColor(QPalette::Window,QColor(53,53,53));
darkPalette.setColor(QPalette::WindowText,Qt::white);
darkPalette.setColor(QPalette::Disabled,QPalette::WindowText,QColor(127,127,127));
darkPalette.setColor(QPalette::Base,QColor(42,42,42));
darkPalette.setColor(QPalette::AlternateBase,QColor(66,66,66));
darkPalette.setColor(QPalette::ToolTipBase,Qt::white);
darkPalette.setColor(QPalette::ToolTipText,Qt::white);
darkPalette.setColor(QPalette::Text,Qt::white);
darkPalette.setColor(QPalette::Disabled,QPalette::Text,QColor(127,127,127));
darkPalette.setColor(QPalette::Dark,QColor(35,35,35));
darkPalette.setColor(QPalette::Shadow,QColor(20,20,20));
darkPalette.setColor(QPalette::Button,QColor(53,53,53));
darkPalette.setColor(QPalette::ButtonText,Qt::white);
darkPalette.setColor(QPalette::Disabled,QPalette::ButtonText,QColor(127,127,127));
darkPalette.setColor(QPalette::BrightText,Qt::red);
darkPalette.setColor(QPalette::Link,QColor(42,130,218));
darkPalette.setColor(QPalette::Highlight,QColor(42,130,218));
darkPalette.setColor(QPalette::Disabled,QPalette::Highlight,QColor(80,80,80));
darkPalette.setColor(QPalette::HighlightedText,Qt::white);
darkPalette.setColor(QPalette::Disabled,QPalette::HighlightedText,QColor(127,127,127));
qApp->setPalette(darkPalette);
Here you can find also a compelte example with frameless window and custom stylesheets to extend the dark palette: https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle
-
Really nice theme! Can I use it in one of my projects? Can you license it? MIT or something? Or can I just copy past it and then license it as MIT? All credits will go to you of course. Feb 6, 2018 at 17:17
-
Just noticed you had this already MIT licensed in your website! Thanks! I will use it and give you the proper credits. Feb 7, 2018 at 10:36
-
-
AFAIK, the color of the Qt5 Fusion theme is entirely controlled by the color palette, which in its turn is controlled by the system theme. So on Ubuntu you'll get Orange colors, and blue on Windows...
So basically all you have to do is to use a tool or the QtProject.conf file to manually tune the color palette for the Qt5 apps, and don't forget to start your app with argument '-style fusion' because elsewere on ubuntu it's started with the GTk+ look emulation.