Resource files can't be opened Windows 7?
-
I am adding "input.txt" to the Resources in the file a .qrc file. On a Windows XP using the MinGW installation it works correctly. On a Windows 7 Visual Studio 2010 installation no resource files can be opened. The QFile.open call fails by returning false:
QFile inputFile(":/input.txt"); bool err = inputFile.open(QIODevice::ReadOnly); if (err == false) return;
The textfinder.prc file:
<RCC>
<qresource prefix="/">
<file>input.txt</file>
</qresource>
</RCC>The TextFinder.pro file has this line:
RESOURCES +=
textfinder.qrcI also tried setting a resource pixmap on a Label. The Label correctly shows the label image in the Qt Designer, but not when the application is run.
How can I get image and text resource files to work on my Windows 7 Qt Creator environment?
Thank you for any assistance.
-
Your code and your .qrc file look okay to me.
Did you check whether your .qrc file did properly get compiled into a .cpp file by Qt RCC? And did you check whether the generated .cpp file did properly get compiled into an .obj file by your compiler (either MSVC or MinGW/GCC)? And, finally, did you check whether the .obj file did get linked into your EXE file?
You could also try:
@QList<QFileInfo> list = QDir(":/").entryInfoList(QStringList("."), QDir::Files);@to enumerate all resources compiled into your app...