I wonder how to copy file that is embeded into app qrc into fs? Stuff like
QFile::copy("qrc:/assets/files/my.file" , "C:/my.file");
seems not to work. Why and how to make it to?
Using a QRC file qrc file in your application you first need to compile it to Python. PyQt5 comes with a command line tool to do this, which takes a . qrc file as input and outputs a Python file containing the compiled data. This can then be imported into your app as for any other Python file or module.
In the Location field, specify a location for the file. Select Add to create a . qrc file and to open it in the Qt Resource Editor. To add resources to the file, select Add > Add Files.
By default, resources are accessible in the application under the same file name as they have in the source tree, with a :/ prefix, or by a URL with a qrc scheme. In this case, the file is accessible as :/myresources/cut-img.
You don't need the qrc
, resources start with a :
eg QFile myFile(":/data/data.xml");
PS: I'm not sure how QFile treats case sensitiveness on resource filenames. For best portability you might want to make sure the case matches whatever is in your qrc
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With