Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can i get the text written in the QTextEdit during run time?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 31.1k Views 1 Watching
  • 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 Offline
    P Offline
    pratik041
    wrote on last edited by
    #1

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

    Pratik Agrawal

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rahul Das
      wrote on last edited by
      #2

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

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


      Declaration of (Platform) independence.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pratik041
        wrote on last edited by
        #3

        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
        0
        • R Offline
          R Offline
          Rahul Das
          wrote on last edited by
          #4

          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]].


          Declaration of (Platform) independence.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            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
            0
            • P Offline
              P Offline
              pratik041
              wrote on last edited by
              #6

              [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
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                [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
                0
                • D Offline
                  D Offline
                  deesha
                  wrote on last edited by
                  #8

                  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
                  0
                  • D Offline
                    D Offline
                    deesha
                    wrote on last edited by
                    #9

                    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
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved