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. Beginner problems with QML and glyphs

Beginner problems with QML and glyphs

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 253 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by A Former User
    #1

    Hi,

    I'm new to QT. At the moment I'm playing around for testing with qml and i encountered a strange problem:
    I started to use the material fonts as icons.

    For this i added the Font in cpp:
    QFontDatabase::addApplicationFont(":/Ressources/MaterialSymbolsOutlined.ttf");

    then i try to use it in QML:
    ToolButton {
    font.family: "MaterialSymbolsOutlined"
    font.pixelSize: 24
    text: "\ue900"
    }

    here i get a totaly wrong icon displayed, while "\ue8ff" as example works just well.

    Do you have got any idea what i'm doing wrong here?

    Thanks

    Edit:
    • Which Qt version are you using? QT 6.10.1
    • Which version of QtCreator are you using? 18.01
    • Which platform? Windows 11
    • How did you install it? Installer

    1 Reply Last reply
    0
    • GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      I would recommend using icons as .svg instead of iconfonts
      Buttons support icon themes : https://doc.qt.io/qt-6/qtquickcontrols-icons.html .
      Write an icon.theme file pointing to a folder with your icons then you could do the following in your code:

      ToolButton {
          icon.name: "zoom_out"
      }
      
      1 Reply Last reply
      1
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Thank you,
        I will take look at it.

        1 Reply Last reply
        0
        • EskilE Offline
          EskilE Offline
          Eskil
          wrote last edited by
          #4

          Which version of the font is this?

          I downloaded the font from the following address and at least for this version, the font family is "Material Symbols Outline" (with spaces), not "MaterialSymbolsOutline":

          https://github.com/google/material-design-icons/blob/master/variablefont/MaterialSymbolsOutlined[FILL%2CGRAD%2Copsz%2Cwght].ttf

          With this font, U+E900 works fine. Is it possible you used the wrong font name in your application? If so, other fonts on the system will be queried for the characters you request, so you may get one font for U+E900 and another one for U+E8FF, depending on what is available and the order they are queried.

          You can get the correct name by calling QFontDatabase::applicationFontFamilies() and pass in the ID that addApplicationFont() returned.

          1 Reply Last reply
          3

          • Login

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