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. Fonts does not work in QT5 application but it works in Qt4

Fonts does not work in QT5 application but it works in Qt4

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 646 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    I have following code

    // get our local fonts
    QString fonts = get_home() + "/lib/fonts/";
    QFontDatabase fontDB;
    fontDB.addApplicationFont(fonts+"LiberationMono-Regular.ttf");
    fontDB.addApplicationFont(fonts+"LiberationMono-Bold.ttf");
    fontDB.addApplicationFont(fonts+"LiberationMono-Italic.ttf");
    fontDB.addApplicationFont(fonts+"LiberationMono-BoldItalic.ttf");
    fontDB.addApplicationFont(fonts+"LiberationSans-Regular.ttf");
    fontDB.addApplicationFont(fonts+"LiberationSans-Bold.ttf");
    fontDB.addApplicationFont(fonts+"LiberationSans-Italic.ttf");
    fontDB.addApplicationFont(fonts+"LiberationSans-BoldItalic.ttf");
    fontDB.addApplicationFont(fonts+"Inconsolata.otf");

    ls ../lib/fonts/

    Inconsolata.otf* LiberationMono-Bold.ttf* LiberationMono-Regular.ttf* LiberationSans-Bold.ttf* LiberationSans-Regular.ttf*
    LiberationMono-BoldItalic.ttf* LiberationMono-Italic.ttf* LiberationSans-BoldItalic.ttf* LiberationSans-Italic.ttf*

    This code is working for QT4 but not working for Qt5 application

    can u please let me know how to set the fonts for Qt5 application

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Qt-Enthusiast said in Fonts does not work in QT5 application but it works in Qt4:

      QFontDatabase::addApplicationFont()

      This has a return value which you could check. Also you should check if ../lib/fonts is the same path as get_home() + "/lib/fonts"

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4
      • Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by
        #3

        yes the path is correct

        JonBJ 1 Reply Last reply
        0
        • Q Qt Enthusiast

          yes the path is correct

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Qt-Enthusiast
          And what about the return result of addApplicationFont(), as @Christian-Ehrlicher asked?

          1 Reply Last reply
          1
          • Q Offline
            Q Offline
            Qt Enthusiast
            wrote on last edited by
            #5

            it is comming as 5

            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