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?
From the Windows Task Manager Press the Ctrl + Alt + Del keys at the same time and select Start Task Manager on the screen that appears. In the Task Manager, click the Performance tab, then click the Resource Monitor button or Open Resource Monitor link, depending on your version of Windows.
If you cannot open your RESOURCE file correctly, try to right-click or long-press the file. Then click "Open with" and choose an application. You can also display a RESOURCE file directly in the browser: Just drag the file onto this browser window and drop it.
Resources are the additional files and static content that your code uses, such as bitmaps, layout definitions, user interface strings, animation instructions, and more. You should always externalize app resources such as images and strings from your code, so that you can maintain them independently.
I had exactly the same problem. Running qmake again finally worked (build -> run qmake).
Does the URL notation
QFile test("qrc:///needle.png");
work for you?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With