[PyKDE] QtextEdit to file?

Tina Isaksen tina at bestemselv.com
Wed Feb 15 21:12:52 GMT 2006


Hans-Peter Jansen wrote:

>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
>
>_______________________________________________
>PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
>http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>  
>
That was easy :)
Big thanks Pete and Andreas




More information about the PyQt mailing list