PDA

View Full Version : QTextEdit simple question



Marcopolo
1st February 2006, 02:28
Hi I'm new in QTDesigner, so my question is very simple.

I created a TextEdit box, where I'll write simple text, then I want to save it into a file.

the file stuff is done, I open a file and I can add data, but my problem is that I dont know how to get the text from the TextEdit box.

how can I get the string from the box?
or how can I put it into mi file ?
Is there something like: myFile<<textEditorBox.getString() ?

I guess this is very simple, but my F1 Help file is missing and tried looking into the forum but I could't find something usefull.

Thanks in advance.

jacek
1st February 2006, 03:09
Try QTextEdit::text().

http://doc.trolltech.com/3.3/qtextedit.html

Marcopolo
1st February 2006, 03:15
thanks for your response
I soleved my problem
bassically I needed this:

myfile << cajaTexto->text();

where "cajaText" is my textEdit..

very simple...

thanks

Carlton
10th October 2007, 23:55
This works fine for Qt3, but doesn't for Qt4.2.3:(
I looked through the Trolltech Qt4 examples for QTextEdit, but found no examples where the edited information was saved to a file.

jacek
11th October 2007, 00:01
This works fine for Qt3, but doesn't for Qt4.2.3
In Qt 4 you have to use QTextEdit::toPlainText() or QTextEdit::toHtml().


I looked through the Trolltech Qt4 examples for QTextEdit, but found no examples where the edited information was saved to a file.
See the demos/textedit.