December 27, 2011

pratik041 pratik041
Lab Rat
346 posts

How can i get the text written in the QTextEdit during run time?

 

I want to save the text written in the QtextEdit by the user.

 Signature 

Pratik Agrawal

6 replies

December 27, 2011

Rahul Das Rahul Das
Robot Herder
362 posts

http://developer.qt.nokia.com/doc/qt-4.8/qtextedit.html#plainText-prop

use the Acces function toPlainText (), which will return what you need.

 Signature 

——————————-

    Rahul Das

——————————-

December 27, 2011

pratik041 pratik041
Lab Rat
346 posts

but how can i save it during run time suppose i want to save it in file by clicking button?

 Signature 

Pratik Agrawal

December 27, 2011

Rahul Das Rahul Das
Robot Herder
362 posts

You have to open a file, write into it. You have the QString from the function toPlainText().

But the easiest way is using QTextDocumentWriter.

 Signature 

——————————-

    Rahul Das

——————————-

December 28, 2011

Volker Volker
Robot Herder
5428 posts

How to do this, is even handled in the most basic Getting started Programming with Qt tutorial.

And please, what is so hard to get a combination of textEdit->toHtml() and file->write() or textstream << string yourself? Is it really that hard?

December 28, 2011

pratik041 pratik041
Lab Rat
346 posts

Volker wrote:
How to do this, is even handled in the most basic Getting started Programming with Qt tutorial.

And please, what is so hard to get a combination of textEdit->toHtml() and file->write() or textstream << string yourself? Is it really that hard?

No it is not hard but i have not seen that documentation before, otherwise i would not have asked it.

 Signature 

Pratik Agrawal

December 28, 2011

Volker Volker
Robot Herder
5428 posts
pratik041 wrote:
No it is not hard but i have not seen that documentation before, otherwise i would not have asked it.

Sorry, but you do not give the impression that you read documentation at all. A quick scan on QTextEdit‘s list of member functions reveals all that secret sauce in no time.

So it either is too hard for you to find out yourself, or you’re plain stinking lazy and asking in the forum instead of doing your research yourself. I’m undecided which alternative is worse.

Anyways, with your behavior, you’re not going to make yourself friends here that are eager to help you, neither with your toy problems nor if you run into really interesting cases.

 
  ‹‹ [SOLVED]How to get emitter of a signal in the slot?      QTextDocument::print ignores # of copies from QPrintDialog ››

You must log in to post a reply. Not a member yet? Register here!