Reputation: 83
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 my project file:
RESOURCES += Resources.qrc
Here is my QRC file:
<RCC>
<qresource prefix="/">
<file>needle.png</file>
</qresource>
</RCC>
I keep getting fail as output. Any ideas?
Upvotes: 8
Views: 12581
Reputation: 1
I removed the project.user.pro file, reopened QT. And it chose the kit and rebuilt. Working now.
Upvotes: 0
Reputation: 615
I had exactly the same problem. Running qmake again finally worked (build -> run qmake).
Upvotes: 11
Reputation: 169
Does the URL notation
QFile test("qrc:///needle.png");
work for you?
Upvotes: 9