Search code examples
c++qtqmake

Include resources from *.pri file


I have some problems with including resources from a *.pri file in Qt. Basically my test.pri file looks like this:

INCLUDEPATH += $$PWD
SOURCES     += $$PWD/testdlg.cpp
HEADERS     += $$PWD/testdlg.h 
FORMS       += $$PWD/testdlg.ui 
RESOURCES   += $$PWD/res.qrc

The *.ico files are stored in a sub folder $$PWD/res and I added them succesfully to my res.qrc file, which looks like this:

<RCC>
    <qresource prefix="/">
        <file>res/Icon1.ico</file>
        <file>res/Icon2.ico</file>
    </qresource>
</RCC>

I include that test.pri file to my *.pro file:

include(Tests/test.pri)

In Qt Designer I can see all the icons when I open my test.ui file. I can chose the icon of a QToolButton (for example) from resource via the property manager of the Designer. Everything works as expected. However, when I compile the applcation, the icons are not displayed.

If I do not use a *.pri file, the icons for the QToolButton are displayed. Can anyone give me a hint what I am missing here?


Solution

  • I don't get what was wrong. After spending yesterday's evening with analysing the problem without any success, I opened Qt creator this morning and everything works fine. Maybe I just had to restart Qt creator after adding the resources? I cannot tell.