[Qt-interest] How to copy an embedded resource file to the file system? [solved]
Marcelo Magno T. Sales
mmtsales at gmail.com
Tue Sep 22 20:53:45 CEST 2009
Em Terça-feira 22 Setembro 2009, Marcelo Magno T. Sales escreveu:
> 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.
I've tried this with other embedded files and the code did work. Only
for one specific resource it doesn't, I don't know why. I'll dig into
that.
Thanks for all who helped,
Marcelo
More information about the Qt-interest-old
mailing list