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. [debug/qrc_fontawsome.cpp] Error 1

[debug/qrc_fontawsome.cpp] Error 1

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 2 Posters 1.2k 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.
  • N Offline
    N Offline
    nanor
    wrote on last edited by
    #3

    @Christian-Ehrlicher Thank you for reply. The directory of the otf file that I want to use is:
    F:\qt codes\fontAwsome2\fontawesome-free-5.15.1-desktop\otfs
    This file exists in my project folder.

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

      This is working fine for me:

      main.cpp

      #include <QtCore>
      int main(int argc, char **argv)
      {
        QCoreApplication app(argc, argv);
        if (QFile::exists(":/my.otf"))
          qDebug() << "File exists";
        else
          qDebug() << "File does not exist";
        return 0;
      }
      

      tmp.qrc:

      <RCC>
        <qresource prefix="/">
          <file alias="my.otf">Font Awesome 5 Free-Regular-400.otf</file>
        </qresource>
      </RCC>
      

      Compiled with

      qmake -proejct
      qmake
      make
      

      The file is from https://github.com/FortAwesome/Font-Awesome/blob/master/otfs/Font Awesome 5 Free-Regular-400.otf

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

      N 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        This is working fine for me:

        main.cpp

        #include <QtCore>
        int main(int argc, char **argv)
        {
          QCoreApplication app(argc, argv);
          if (QFile::exists(":/my.otf"))
            qDebug() << "File exists";
          else
            qDebug() << "File does not exist";
          return 0;
        }
        

        tmp.qrc:

        <RCC>
          <qresource prefix="/">
            <file alias="my.otf">Font Awesome 5 Free-Regular-400.otf</file>
          </qresource>
        </RCC>
        

        Compiled with

        qmake -proejct
        qmake
        make
        

        The file is from https://github.com/FortAwesome/Font-Awesome/blob/master/otfs/Font Awesome 5 Free-Regular-400.otf

        N Offline
        N Offline
        nanor
        wrote on last edited by nanor
        #5

        @Christian-Ehrlicher I downloaded the file from the link you provided and put it into my project folder. Also I wrote your suggested code and got "File exists".
        Now I got no errors, but I got the following result:

        uni.png

        The unicode I used is from here

        I changed the code in the resource file as you posted:

        <RCC>
          <qresource prefix="/">
            <file alias="my.otf">Font Awesome 5 Free-Regular-400.otf</file>
          </qresource>
        </RCC>
        
        

        Also, I updated my cpp file as your posted code:

        #include "dialog.h"
        #include "ui_dialog.h"
        #include <QFontDatabase>
        #include <QFont>
        #include <QPushButton>
        
        Dialog::Dialog(QWidget *parent) :
            QDialog(parent),
            ui(new Ui::Dialog)
        {
            ui->setupUi(this);
        
        
            QFontDatabase::addApplicationFont(":/my.otf");
        
            QFont font;
            font.setFamily("FontAwesome");
            font.setPixelSize(32);
        
        
            QPushButton *button = new QPushButton(this);
            button->setFont(font);
            button->setText("\uf083");
        
        }
        
        Dialog::~Dialog()
        {
            delete ui;
        }
        
        
        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #6

          I don't know what symbol is behind "\uf083" nor do I know if the font contains this symbol.

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

          N 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            I don't know what symbol is behind "\uf083" nor do I know if the font contains this symbol.

            N Offline
            N Offline
            nanor
            wrote on last edited by nanor
            #7

            @Christian-Ehrlicher The unicode " f083" is from here. This is the unicode for camera.
            The code I posted above is from here.
            I am supposed to have something like this:
            camera.png

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

              I can't see what's going wrong here. My only idea would be that the symbol is not available but I can't test it.
              If you think this is a Qt bug please open a bugreport at https://bugreports.qt.io

              /edit: I did some more testing and would guess the symbol is not in the otf file - see http://prntscr.com/vbba17 - only a few icons are shown.

              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
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by Christian Ehrlicher
                #9

                Ok, it's in Font Awesome 5 Free-Solid-900.otf in the free part available from https://fontawesome.com/download

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

                N 1 Reply Last reply
                1
                • Christian EhrlicherC Christian Ehrlicher

                  Ok, it's in Font Awesome 5 Free-Solid-900.otf in the free part available from https://fontawesome.com/download

                  N Offline
                  N Offline
                  nanor
                  wrote on last edited by
                  #10

                  @Christian-Ehrlicher Thank you so much for helping. I downloaded Awesome 5 Free-Solid-900.otf from the link you provided, but stilI got the picture bellow:

                  uni.png

                  I also downloaded the svg file from here, and I got the same output!

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

                    It is working fine for me when I add Font Awesome 5 Free-Solid-900.otf to the resource file and load the font from there.
                    Don't know what you want with the svg though.

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

                    N 1 Reply Last reply
                    0
                    • Christian EhrlicherC Christian Ehrlicher

                      It is working fine for me when I add Font Awesome 5 Free-Solid-900.otf to the resource file and load the font from there.
                      Don't know what you want with the svg though.

                      N Offline
                      N Offline
                      nanor
                      wrote on last edited by
                      #12

                      @Christian-Ehrlicher Could you please send me your code, if its possible? Thanks.

                      Christian EhrlicherC 1 Reply Last reply
                      0
                      • N nanor

                        @Christian-Ehrlicher Could you please send me your code, if its possible? Thanks.

                        Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        @nanor I already posted my code above, simply replace the filename for the otf file.

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

                        N 1 Reply Last reply
                        0
                        • Christian EhrlicherC Christian Ehrlicher

                          @nanor I already posted my code above, simply replace the filename for the otf file.

                          N Offline
                          N Offline
                          nanor
                          wrote on last edited by
                          #14

                          @Christian-Ehrlicher I downloaded the fontawesome.ttf file from here and my code works fine now.
                          I don't know why Font Awesome 5 Free-Solid-900.otf didn't work for me, but the fontawesome used in the posted link project, works for my project.
                          I really thank you for you help. Your provided codes helped me a lot.
                          Best regards.

                          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