[Qt-interest] How to edit a file present in a resource at run-time ?

Raja Rokkam rokkamraja at gmail.com
Mon Nov 2 12:42:13 CET 2009


Hi,

   If you have modified the txt file, you need to compile the resource file
again using rcc . This link wud be helpful:
http://docs.huihoo.com/qt/4.5/resources.html

-Raja.

On Mon, Nov 2, 2009 at 4:35 PM, Andre Somers <andre at familiesomers.nl> wrote:

> Louis Du Verdier wrote:
> > Hello,
> >
> > For a project, I have to edit a file present in a resource, but at
> > run-time.
> > I tried this code to test :
> >
> >     QFile f(":/Test.txt");
> >     if(!f.open(QIODevice::ReadWrite | QIODevice::Text))
> >     {
> >         QMessageBox::critical(this, "Test", "Not working...");
> >         return;
> >     }
> >     f.write(QString("OK !").toAscii());
> >     QTextEdit *t = new QTextEdit(f.readAll());
> >     t->show();
> >
> > But the messageBox tell me that the file cannot be open in the
> > ReadWrite mode.
> > I took a look in QRessource but nothing speak about how to write into
> > a file present in the ressource.
> > So, how to write into a file present in the ressource when the
> > application is running ?
> >
> The answer is simple: you don't.
> The resource is compiled into the executable itself. You can not change
> the executable you are running from that same executable. I hope my
> anti-virus software would stop any program trying to do that...
>
> I would work around your problem by storing the modified version of your
> file on disk. You can then use the disk version if it exists, and the
> embedded version if it doesn't.
>
> André
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091102/e008045e/attachment.html 


More information about the Qt-interest-old mailing list