| This is geared towards qtquick (not widgets) applications, but to create a general theme you can use this pattern: https://doc.qt.io/archives/qt-5.11/qtquickcontrols2-flatstyl... Then before the engine is loaded in main.cpp call qmlRegisterSingleton( QUrl(QStringLiteral("qrc:/Theme.qml")), "mycustomname.theme", 1, 0, "Theme"); Then in a qml file: import mycustomname.theme 1.0 This allows you to do something like: Rectangle {
width: 100
height: 100
color: Theme.mainColor
} You can also do things like set the application font which would be done in main.cpp before the engine is loaded: QFont appFont("NameOfLoadedFont);
appFont.setPixelSize(16);
QGuiApplication::setFont(appFont); You would need to load the font, which you can do in the Theme.qml file: property FontLoader someFont: FontLoader {
source: "qrc:/locationOfFont/Font"
name: "NameOfLoadedFont"
} |