Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
Resource files can't be opened Windows 7?
dlafreniere last edited by
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:
The TextFinder.pro file has this line:
I 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.
MuldeR last edited by
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...