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

QlineEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.6k Views 3 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.
  • S Offline
    S Offline
    shree_qt
    wrote on last edited by
    #1

    How to get access of QlineEdit?
    something like this:
    ui_filename->textEdit->plainText();
    What is the right syntax?
    Actually i want take input from the user and write it into the file using qlineEdit?
    If you sent sample code of given above problem using data serialization it will be much helpful

    mrjjM 1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @shree_qt For QLineEdit the correct method is text(). If you want to put just the text into a file then use QTextStream and if you want to serialize objects then look for QDataStream

      157

      1 Reply Last reply
      2
      • S shree_qt

        How to get access of QlineEdit?
        something like this:
        ui_filename->textEdit->plainText();
        What is the right syntax?
        Actually i want take input from the user and write it into the file using qlineEdit?
        If you sent sample code of given above problem using data serialization it will be much helpful

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @shree_qt

        Save is pretty straightforward if you just want to save text

        #include <QFile>
        #include <QTextStream>
        
        int save()
        {
            QString filename = "c:/thepath/Data.txt";
            QFile file(filename);
            if (file.open(QIODevice::ReadWrite)) {
                QTextStream stream(&file);
                stream << "something" << endl;
            } else
            qDebug() << "save failed";
        
        }
        
        1 Reply Last reply
        4
        • S Offline
          S Offline
          shree_qt
          wrote on last edited by
          #4

          I want to write into file as given input by user in qLineEdit. Something like assigning a user value to variable and writing it into file. What can i do for it?

          p3c0P 1 Reply Last reply
          0
          • S shree_qt

            I want to write into file as given input by user in qLineEdit. Something like assigning a user value to variable and writing it into file. What can i do for it?

            p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by p3c0
            #5

            @shree_qt check the example provided by @mrjj. You have to pass data from lineedit to that function and then to textstream

            157

            1 Reply Last reply
            1

            • Login

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