Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy qrc resource file into filesystem?

Tags:

c++

qt

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?

like image 681
myWallJSON Avatar asked May 23 '12 17:05

myWallJSON


People also ask

How do I use QRC files?

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.

How do I add a QRC file to QTC?

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.

Where is resources QRC?

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.


1 Answers

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.

like image 108
Martin Beckett Avatar answered Oct 13 '22 19:10

Martin Beckett