Dark theme does not apply to the title bar

Viewed 587

I have applied a dark style to my application, so good until then, my question is why the style is not applied to the title bar of my application, and the rest of the forms that open in me application, as you can see, it stays white and looks very bad, any suggestions would be appreciated.

enter image description here

#include "mainwindow.h"

#include <QApplication>
#include <QFile>
#include <QTextStream>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QFile f(":/qdarkstyle/style.qss");
    f.open(QIODevice::ReadOnly|QIODevice::Text);
    QTextStream ts(&f);
    a.setStyleSheet(ts.readAll());

    MainWindow w;
    w.show();
    return a.exec();
}

I got the subject from here. https://github.com/ColinDuquesnoy/QDarkStyleSheet

1 Answers

[Works on Qt 6.2.2, not sure about Qt5]

There might be a configuration file qt.conf in the same folder as your executable file. If it does not exist, create. And add the lines

[Platforms]
WindowsArguments = darkmode=1

Use darkmode=2 if you also want to change the title bar colour on the fly.

Related