I need to receive the absolute file path like
C:/Users/Dima/YandexDisk/_Application/WeldAnalysis/ExperimentDefaults.xlsx
from path of QRC file like
:/Data/ExperimentDefaults.xlsx.
How can I do this?
I need to receive the absolute file path like
C:/Users/Dima/YandexDisk/_Application/WeldAnalysis/ExperimentDefaults.xlsx
from path of QRC file like
:/Data/ExperimentDefaults.xlsx.
How can I do this?
Resources are packed all together into the QRC file, they are not exposed to the filesystem, thus they cannot be converted to a standard path; it is like accessing a file inside a zip file.
What are you willing to do with such file path?
QFilecan deal with resource paths (":/...") and open such files, but other file handling APIs don't (such as C'sfopenor C++'sstd::ifstream). Also, and for the same reason, non-Qt application won't be able to open such files if passed as a parameter.Options you have include:
opening the file using
QFileand read it using related Qt classes (given you are dealing with an Excel file I think it doesn't worth the effort, unless you have some library to read it from a memory buffer).copying the file out of the resources container to a temporary directory (you can use
QTemporaryDirto create one), and use the file from there:Only be aware that when
tempDiris destroyed, the temporary directory is also deleted, therefore your file. You can avoid this by disabling the auto-remove feature:tempDir.setAutoRemove(false)and manually deleting the temporary directory when you finish with the extracted file.