-1

I am trying to use a qrc (resource) file to load ui icons and fonts I want to use.

rvnsrc.qrc:

<RCC>
    <qresource prefix="/rvn">
        <file>Sources/Images/downarrow.png</file>
        <file>Sources/Images/left-hover.png</file>
        <file>Sources/Images/left-idle.png</file>
        <file>Sources/Images/MemoryIcon.png</file>
        <file>Sources/Images/OutSourceImage.png</file>
        <file>Sources/Images/pause-hover.png</file>
        <file>Sources/Images/pause-idle.png</file>
        <file>Sources/Images/play-hover.png</file>
        <file>Sources/Images/play-idle.png</file>
        <file>Sources/Images/right-hover.png</file>
        <file>Sources/Images/right-idle.png</file>
        <file>Sources/Images/uparrow.png</file>
        <file>Sources/Fonts/AzeretMono-Light.ttf</file>
        <file>Sources/Fonts/AzeretMono-Medium.ttf</file>
        <file>Sources/Fonts/AzeretMono-Regular.ttf</file>
        <file>Sources/Fonts/AzeretMono-SemiBold.ttf</file>
    </qresource>
</RCC>

.qrc file is located next to my .pro file.

All the files given above are located in the correct path as given in the qrc file.

In the .pro file I included the resource file as given below:

RESOURCES += \
    rvnsrc.qrc

And for instance, I try to use it as given below:

int idBold = QFontDatabase::addApplicationFont(":/rvn/Sources/Fonts/AzeretMono-Bold.ttf");

The font cannot be loaded.

I added a txt file to the resource file tried to read it. QFile couldn't find it either.

Then I wanted to check where the symbol ":" directs me and I put the code section below into my project :

QDirIterator it(":", QDirIterator::Subdirectories);
    while (it.hasNext()) {
        qDebug() << it.next();
    }

The output of the previous code block looks like as given below :

":/qt-project.org"
":/qt-project.org/qmime"
":/qt-project.org/qmime/packages"
":/qt-project.org/qmime/packages/freedesktop.org.xml"
":/qt-project.org/styles"
":/qt-project.org/styles/commonstyle"
...
":/qt-project.org/styles/commonstyle/images"
":/qt-project.org/styles/commonstyle/images/networkdrive-16.png"
":/qt-project.org/styles/commonstyle/images/networkdrive-32.png"
":/qt-project.org/styles/commonstyle/images/dvd-16.png"
":/qt-project.org/styles/commonstyle/images/cdr-16.png"
":/qt-project.org/styles/commonstyle/images/standardbutton-clear-128.png"
":/qt-project.org/styles/commonstyle/images/standardbutton-close-128.png"
":/qt-project.org/styles/macstyle"":/qt-project.org/styles/macstyle/images"
":/qt-project.org/styles/macstyle/images/toolbar-ext.png"
":/qt-project.org/styles/macstyle/images/dockdock-down-16.png"
":/qt-project.org/styles/macstyle/images/closedock-16.png"
":/qt-project.org/styles/macstyle/images/dockdock-16.png"
":/qt-project.org/styles/macstyle/images/closedock-down-16.png"
":/qt-project.org/styles/macstyle/images/toolbar-ext@2x.png"
":/qt-project.org/qmessagebox"":/qt-project.org/qmessagebox/images"
":/qt-project.org/qmessagebox/images/qtlogo-64.png"":/qgradient"
":/qgradient/webgradients.binaryjson"":/qpdf"
":/qpdf/qpdfa_metadata.

Of course, I deleted some lines for the sake of simplicity.

Passing the below url format as an argument didn't work:

qrc:/rvn/Sources/Fonts/AzeretMono-SemiBold.ttf

There are other solutions I tried :

  • Running qmake on the project
  • Changing build directory
  • Deleting build folder, depleting pro user file, running qmake then clean building the project
  • Creating another resource file and trying to load sources from that qrc file.

And the most weird thing about the problem is :

I have two computers. One of them is a simple amd x64 ubuntu laptop, other one is nvidia orin aarm.

I built Qt itself on both machines with same procedures. I built Qt Creator on both machines with the same procedures.

There is no error on the amd x64 one but I receive this error on the arm based nvidia card.

  • Could you please provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example)? something like this: https://hastebin.com/share/ugiwexiyuv.cpp, and share your project folder structure. – Abderrahmene Rayene Mihoub Aug 21 '23 at 11:35
  • Hi, Batuhan. Can you try to load font file from the disk with an absolute path such as "C:/path./to/font/font.ttf" ? – Lady Be Good Aug 22 '23 at 18:01
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Aug 24 '23 at 12:11

0 Answers0