[PyKDE] QtextEdit to file?

Hans-Peter Jansen hpj at urpla.net
Wed Feb 15 20:26:45 GMT 2006


Am Mittwoch, 15. Februar 2006 18:47 schrieb Andreas Pakulat:
> On 15.02.06 18:19:42, Tina Isaksen wrote:
> > I need to save the contents of a QtextEdit box as a file text-file,
> > retaining the carriage returns. I've been googling for an hour,
> > studied QT-assistant, and I just don't get it... as usual. Any
> > assistance will be greatly apreciated.
> >
> >From the QTextEdit you get a QString. You can then use this QString
> > and
>
> put it into a QDataStream. This one is created with a QFile which
> resembles the actual file.

or just (depending on the required encoding):
	open("text.txt", "w").write(QTextEdit.text().utf8())

Hth,
Pete




More information about the PyQt mailing list