Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.11
-
None
Description
I have a custom style that only provides Button.qml. The style should have a custom font, which is specified in the qtquickcontrols2.conf file:
qtquickcontrols2.conf
[Controls] Style=:/style FallbackStyle=Fusion [:/style] ;[style] Font\Family=Swis721 Cn BT D-Type Font\PixelSize=20
The font is loaded in C++:
main.cpp
#include <QGuiApplication> #include <QQmlApplicationEngine> #include <QFontDatabase> #include <QDebug> int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); const int fontId = QFontDatabase::addApplicationFont(":/Swis721 Cn BT D-Type.ttf"); if (fontId == -1) { qWarning() << "Failed to load application font!"; } else { QFont font("Swis721 Cn BT D-Type", 10); QGuiApplication::setFont(font); } QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }
However, the custom Button uses the wrong font:
style/Button.qml
import QtQuick 2.9 import QtQuick.Templates 2.2 as T T.Button { id: control implicitWidth: 200 implicitHeight: 40 contentItem: Text { text: control.text font: control.font color: "white" } background: Rectangle { color: "#444" } }
Attachments
Issue Links
- relates to
-
QTBUG-67062 Add full/public theming support for QQC2 styles
- Open
Gerrit Reviews
For Gerrit Dashboard: QTBUG-68087 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
229114,11 | Create and init QQuickTheme from QtQuickControls2Plugin | dev | qt/qtquickcontrols2 | Status: MERGED | -2 | 0 |
229205,3 | Read qtquickcontrols2.conf for custom styles | dev | qt/qtquickcontrols2 | Status: ABANDONED | +2 | 0 |