Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

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

    General and Desktop
    4
    9
    30598
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      pratik041 last edited by

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

      Pratik Agrawal

      1 Reply Last reply Reply Quote 0
      • R
        Rahul Das last edited by

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

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


          Rahul Das
        

        1 Reply Last reply Reply Quote 0
        • P
          pratik041 last edited by

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

          Pratik Agrawal

          1 Reply Last reply Reply Quote 0
          • R
            Rahul Das last edited by

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

            But the easiest way is using [[doc:QTextDocumentWriter]].


              Rahul Das
            

            1 Reply Last reply Reply Quote 0
            • G
              goetz last edited by

              How to do this, is even handled in the most basic "Getting started Programming with Qt":/doc/qt-4.8/gettingstartedqt.html 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?

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply Reply Quote 0
              • P
                pratik041 last edited by

                [quote author="Volker" date="1325028679"]How to do this, is even handled in the most basic "Getting started Programming with Qt":/doc/qt-4.8/gettingstartedqt.html 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?[/quote]

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

                Pratik Agrawal

                1 Reply Last reply Reply Quote 0
                • G
                  goetz last edited by

                  [quote author="pratik041" date="1325045378"]
                  No it is not hard but i have not seen that documentation before, otherwise i would not have asked it.[/quote]

                  Sorry, but you do not give the impression that you read documentation at all. A quick scan on [[Doc: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.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply Reply Quote 0
                  • D
                    deesha last edited by

                    hello, i have used toplaintext method to get the text entered by the user and i save it in a file through wostream, but i get the commas and new lines entered by the user as , and \n etc which is not what i want..a relevant part of my code is below:

                     key=ui->textEdit->toPlainText().toStdWString();
                     json->AsObject()[L"guards"] = new JSONValue(key);
                     std::wstring st = json->Stringify();
                     myfile1 << st;
                      myfile1.close();
                    

                    Please help as I am relatively new in C++ and need urgent help..

                    1 Reply Last reply Reply Quote 0
                    • D
                      deesha last edited by

                      hello, i have used toplaintext method to get the text entered by the user and i save it in a file through wostream, but i get the commas and new lines entered by the user as , and \n etc which is not what i want..a relevant part of my code is below:

                       key=ui->textEdit->toPlainText().toStdWString();
                       json->AsObject()[L"guards"] = new JSONValue(key);
                       std::wstring st = json->Stringify();
                       myfile1 << st;
                        myfile1.close();
                      

                      Please help as I am relatively new in C++ and need urgent help..

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post