4 ms·
Can someone please show me how to style a qt app relatively easily? I've built qt applications, and making some effort to make it look passable takes twice as m
by kart23 7y ago
Can someone please show me how to style a qt app relatively easily? I've built qt applications, and making some effort to make it look passable takes twice as much time as actual programming. QSS just sucks in making luxurious feeling interfaces, and this is where electron succeeds. Its much easier to make your own 'widgets' and have a great feeling application at the expense of ram and performance on electron. If Qt fixes styling, I would be onboard 100%. Performance is amazing and I like being able to develop one codebase for all operating systems.
- anmorgan 7y agoThis 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-flatstyle-imports-theme-theme-qml.html 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" }