这是我的代码:
QFile test("://needle.png"); // also tried :/needle.png :\needle.png :\\needle.png
if(test.open(QFile::ReadOnly)) {
qDebug() << "yay";
} else {
qDebug() << "fail";
}
我的项目文件中有这个:
RESOURCES += Resources.qrc
这是我的QRC文件:
<RCC>
<qresource prefix="/">
<file>needle.png</file>
</qresource>
</RCC>
我不断失败作为输出。有任何想法吗?
最佳答案
URL表示法
QFile test("qrc:///needle.png");
为你工作?
关于qt - 无法打开资源文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15989149/