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

Marcelo Magno T. Sales mmtsales at gmail.com
Tue Sep 22 20:32:04 CEST 2009


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




More information about the Qt-interest-old mailing list