Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the Qt 5 dark Fusion theme available for Windows?

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.

like image 812
Christian Ivicevic Avatar asked Feb 23 '13 01:02

Christian Ivicevic


People also ask

Does QT have a dark mode?

If you have selected a system-wide option to prefer a dark theme, doc.qt.io follows that automatically. You can also toggle the theme on the website to override this default setting, by clicking the corresponding icon on the right side of the header.

How do I change the theme on my Qt Creator?

To switch themes, select Edit > Preferences > Environment, and then select a theme in the Theme field. You can use the Qt Creator text and code editors with your favorite color scheme that defines how code elements are highlighted and which background color is used.


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.

like image 94
Skyrpex Avatar answered Oct 31 '22 07:10

Skyrpex


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

like image 32
Jorgen Avatar answered Oct 31 '22 09:10

Jorgen


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.

like image 3
TheBootroo Avatar answered Oct 31 '22 08:10

TheBootroo