[Qt-interest] How to copy an embedded resource file to the file system?

cyril.mailing.list cyril.mailing.list at gmail.com
Tue Sep 22 20:44:03 CEST 2009


Marcelo Magno T. Sales a écrit :
> Em Terça-feira 22 Setembro 2009, Stephen Jackson escreveu:
>   
>> On Tue, Sep 22, 2009 at 12:06 AM, Marcelo Magno T. Sales wrote:
>>     
>>> Hello,
>>>
>>> I would like to copy a file which is embedded in the executable (as
>>> a qt resource) to the file system. How to achieve that?
>>> QFile::copy() fails with error 14 (copy error).
>>>
>>> I've tried something like:
>>> QFile(":/path/file").copy("/path/in/filesystem/file");
>>>
>>> or
>>>
>>> QFile file(":/path/file");
>>> file.copy("/path/in/filesystem/file");
>>>
>>> But it fails with the above mentioned error (checked with
>>> QFile::error())
>>>
>>> Thanks,
>>>       
>> Both of the above methods work for me (Qt 4.5.1 on Linux), i.e. the
>> functions return true, the file is copied and the copy compares equal
>> (with cmp) to the original. What does errno indicate?
>>     
>
> I'm running Qt 4.5.0 on Kubuntu 9.04.
> errno indicates error #2 (no such file or directory). However, the 
> resource path is ok... The destination file do not exist indeed, of 
> course.
>
> Thanks,
>
> Marcelo
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   

Have you tried to open your QFile(":/path/file") and read its contents 
programatically?
Have you stepped into QFile::copy() using a debugger?



More information about the Qt-interest-old mailing list