Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Quick Controls 2 Material Theme font (Roboto) problem
Forum Updated to NodeBB v4.3 + New Features

Quick Controls 2 Material Theme font (Roboto) problem

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 1 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MCoder
    wrote on last edited by MCoder
    #1

    I created example project containig only one button and Material Theme. (using Wizard in Qt Creator)

    Main.cpp:

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
        if (engine.rootObjects().isEmpty())
            return -1;
    
        return app.exec();
    }
    

    main.qml:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Controls 2.12
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Button{
            text: "Test"
            highlighted: true
        }
    }
    

    qtquickcontrols2.conf:

    [Controls]
    Style=Material
    
    [Material]
    Primary=#1976D2
    Accent=#FF5722
    

    When I run thisaxample I see this:
    0_1550392066825_111.JPG

    Font on the button is very small and it is not Roboto font.
    (family MS Shell Dlg 2, pixel size: 8)

    I have installed Robot font in my system because if I add font family to button all works file.
    main.qml:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Controls 2.12
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Button{
            text: "Test"
            highlighted: true
            font.family: "Roboto"
            font.pixelSize: 14
        }
    }
    
    

    0_1550392271260_222.JPG

    It is really Roboto font 14 px. But as I see in source code font is set in start of application.

    http://code.qt.io/cgit/qt/qtquickcontrols2.git/tree/src/imports/controls/material/qquickmaterialtheme.cpp

    Lets see... Font family and font size are set at startup.

    Please tell me this is bug or I missing something?

    Thank you.

    P.S. My test system is: Qt 5.12.1, MinGW 7.3.0 64 bit, Windows 10

    M 1 Reply Last reply
    0
    • M MCoder

      I created example project containig only one button and Material Theme. (using Wizard in Qt Creator)

      Main.cpp:

      #include <QGuiApplication>
      #include <QQmlApplicationEngine>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
      
          QGuiApplication app(argc, argv);
      
          QQmlApplicationEngine engine;
          engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
          if (engine.rootObjects().isEmpty())
              return -1;
      
          return app.exec();
      }
      

      main.qml:

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.12
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          Button{
              text: "Test"
              highlighted: true
          }
      }
      

      qtquickcontrols2.conf:

      [Controls]
      Style=Material
      
      [Material]
      Primary=#1976D2
      Accent=#FF5722
      

      When I run thisaxample I see this:
      0_1550392066825_111.JPG

      Font on the button is very small and it is not Roboto font.
      (family MS Shell Dlg 2, pixel size: 8)

      I have installed Robot font in my system because if I add font family to button all works file.
      main.qml:

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.12
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          Button{
              text: "Test"
              highlighted: true
              font.family: "Roboto"
              font.pixelSize: 14
          }
      }
      
      

      0_1550392271260_222.JPG

      It is really Roboto font 14 px. But as I see in source code font is set in start of application.

      http://code.qt.io/cgit/qt/qtquickcontrols2.git/tree/src/imports/controls/material/qquickmaterialtheme.cpp

      Lets see... Font family and font size are set at startup.

      Please tell me this is bug or I missing something?

      Thank you.

      P.S. My test system is: Qt 5.12.1, MinGW 7.3.0 64 bit, Windows 10

      M Offline
      M Offline
      MCoder
      wrote on last edited by MCoder
      #2

      Addition

      But if I compile with Qt 5.9.7 all works fine.

      main.qml:

      import QtQuick 2.9
      import QtQuick.Window 2.3
      import QtQuick.Controls 2.2
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          Button{
              text: "Test"
              highlighted: true
          }
      }
      

      0_1550392954913_333.JPG

      Only button text in uppercase.

      Please tell me what difference and what I miss in new version?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved