Search code examples
c++qtqt5.3qfileinfo

last modified date of file in Qt resource system


Normally you can get last modified date easily with QFileInfo::lastModified(). However this doesn't work when a file inside Qt's resource system is used

QFileInfo resourceInfo("://resource.txt");
qDebug() << resourceInfo.lastModified().toString() // returns ""

Is there a possibility to find out the last modified date without temporarily copying the file from the resources to the file system?


Solution

  • When you add a file to a resource, it's compiled into the final executable binary, so there is no concept of a file as there is in the filesystem, which is why lastModified doesn't return a value.