Cannot open resource file.

Here is my code:

QFile test("://needle.png"); // also tried :/needle.png :\needle.png :\\needle.png

if(test.open(QFile::ReadOnly)) {
    qDebug() << "yay";
} else {
    qDebug() << "fail";
}

I have this in the project file:

RESOURCES += Resources.qrc

Here is my QRC file:

<RCC>
    <qresource prefix="/">
        <file>needle.png</file>
    </qresource>
</RCC>

I continue to work with an error. Any ideas?

+5
source share
3 answers

Is URL notation

QFile test("qrc:///needle.png");

works for you?

+4
source

I had exactly the same problem. Running qmake again finally worked (build -> run qmake).

+9
source

I deleted the project.user.pro file, reopened QT. And he chose the kit and rebuilt. Now we are working.

0
source

All Articles