Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] QDir with a QResource path is not initialized in the constructor
I have the following problem :
The QDir is not initialized but the QFile is. The QResource paths and prefixes are double-checked so they point to the right places. Initializing the QDir with an absolute file system path works fine too.
Any ideas what am I doing wrong?
Edit: Clarified the title a little :-)
Seems indeed strange. Try passing "qrc:/Icons/languages"), or construct the path with QUrl.
Is this in Qt4 or Qt5?
Thanks for your reply sierdzio.
I found the problem, although I don't understand why is happening. The weirdness with the path occurs when I try to use the resources in a separate library that I link statically in the main app. If I move the resources from the library's .pro file to the main app's .pro file, then the constructor in the library works fine... I would still prefer to use these resources in the separate library though.
This is Qt5 on OS X and Linux.
Hostel last edited by
Did you read "Using Resources in the Application":http://qt-project.org/doc/qt-5.0/qtcore/resources.html#using-resources-in-the-application and try?
If you have resources in a static library, you might need to force initialization of your resources by calling Q_INIT_RESOURCE() with the base name of the .qrc file. For example:
int main(int argc, char *argv)
QApplication app(argc, argv);
Maybe this help.
Apparently I missed that part in the doc... It works fine now.
Thank you Hostel.