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. Managing QFontDatabase on Windows 10 Home
Forum Updated to NodeBB v4.3 + New Features

Managing QFontDatabase on Windows 10 Home

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.5k 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.
  • D Offline
    D Offline
    DebugBSD
    wrote on last edited by
    #1

    Hi, good morning

    I'm working on a Project which runs on Windows 10 Home edition. I've installed Qt 5.7.0 and I'm using the Visual Studio C++ compiler in the project.
    Mi problem comes when I try to manage font files into my program with QFontDatabase. I don't understand why, but, when I try to remove the font from my Windows Operating System I can't do that. I always get false when I call QFile::remove(). I'll try to be more specific with an example:

    QString fontFile = "C:/some/directory/font.ttf";

    int fontId = QFontDatabase::addApplicationFont(fontFile);
    QStringList listOfFamilies = QFontDatabase::applicationFontFamilies(fontId);

    /* Do somethjing here ... */

    QFontDatabase::removeApplicationFont(fontId);
    qDebug() << "Removing " << fontFile << " returns " << QFile::remove(fontFile);

    I don't know why, but I always get false, and it shouldn't because the font is not used anymore.

    Do you have any idea about why I'm getting always the same error?

    I need to delete the file, because the program runs on git, and it will be necessary to delete fonts from the project as needed. If I cannot delete the file, I will have problems doing merge's between employees working on the same project.

    Thanks in advance!
    Have a nice day.

    Happy Hacking! :)

    jsulmJ 1 Reply Last reply
    0
    • D DebugBSD

      Hi, good morning

      I'm working on a Project which runs on Windows 10 Home edition. I've installed Qt 5.7.0 and I'm using the Visual Studio C++ compiler in the project.
      Mi problem comes when I try to manage font files into my program with QFontDatabase. I don't understand why, but, when I try to remove the font from my Windows Operating System I can't do that. I always get false when I call QFile::remove(). I'll try to be more specific with an example:

      QString fontFile = "C:/some/directory/font.ttf";

      int fontId = QFontDatabase::addApplicationFont(fontFile);
      QStringList listOfFamilies = QFontDatabase::applicationFontFamilies(fontId);

      /* Do somethjing here ... */

      QFontDatabase::removeApplicationFont(fontId);
      qDebug() << "Removing " << fontFile << " returns " << QFile::remove(fontFile);

      I don't know why, but I always get false, and it shouldn't because the font is not used anymore.

      Do you have any idea about why I'm getting always the same error?

      I need to delete the file, because the program runs on git, and it will be necessary to delete fonts from the project as needed. If I cannot delete the file, I will have problems doing merge's between employees working on the same project.

      Thanks in advance!
      Have a nice day.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @DebugBSD Do you have write access in the directory where the font file is located?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DebugBSD
        wrote on last edited by
        #3

        @jsulm Yes, bacuase, I can delete the file if I press Supr key on the file selected in the folder.

        Happy Hacking! :)

        jsulmJ 2 Replies Last reply
        0
        • D DebugBSD

          @jsulm Yes, bacuase, I can delete the file if I press Supr key on the file selected in the folder.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @DebugBSD Maybe the font file is still opened by your application?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • D DebugBSD

            @jsulm Yes, bacuase, I can delete the file if I press Supr key on the file selected in the folder.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @DebugBSD Also you can use non-static remove method and print out the error string using http://doc.qt.io/qt-5/qiodevice.html#errorString

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DebugBSD
              wrote on last edited by
              #6

              thanks @jsulm a lot. I'll try to get more info about the error with errorString

              Happy Hacking! :)

              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