Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to set a font from a ini file?
Forum Updated to NodeBB v4.3 + New Features

How to set a font from a ini file?

Scheduled Pinned Locked Moved General and Desktop
ini
2 Posts 1 Posters 813 Views 1 Watching
  • 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.
  • Lays147L Offline
    Lays147L Offline
    Lays147
    wrote on last edited by
    #1

    So? How to set a front from a ini file? Because i have some problems with the qt fonts(because the error: font database cannot find font directory - is qt installed correctly) . So i want use fonts default of system.

    Here what i did:
    [General]
    Fonts=QCoreApplication::applicationDirPath()/fonts/Ubuntu-R
    Is the folder content with the ttf font. How do i set on my qt project?

    Any tips?

    Lays Rodrigues
    Newby on Qt - Learning always!
    Using QT 5.7
    ArchLinux

    1 Reply Last reply
    0
    • Lays147L Offline
      Lays147L Offline
      Lays147
      wrote on last edited by Lays147
      #2

      @JKSH @SGaist Well, i did this in my code in main.cpp
      QString fontPath = ":/Fonts/Ubuntu-R.ttf";
      int fontId = QFontDatabase::addApplicationFont(fontPath);
      if (fontId != -1)
      {
      QFont font("MyFont");
      app.setFont(font);
      }

      It did works, but the error appears, this time only the first line terminal (Before appeared n times). But the program normally performs. Can anyone tell me why the error (FontDatabase) persist?
      Ps.: I build my app with qt libraries STATIC. Exists another way to fix the font problem in the project without this way that i did?

      Lays Rodrigues
      Newby on Qt - Learning always!
      Using QT 5.7
      ArchLinux

      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