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. help write code
Qt 6.11 is out! See what's new in the release blog

help write code

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 687 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.
  • Q Offline
    Q Offline
    Qwerty123098
    wrote on last edited by
    #1

    I created lineEdit, button, and password generator engine , password is generated in lineEdit, and so, when I click this button, I want to save the password in a .txt file. Who can write such code.
    My Qt version is 5.14

    VRoninV Pl45m4P 2 Replies Last reply
    0
    • Q Qwerty123098

      I created lineEdit, button, and password generator engine , password is generated in lineEdit, and so, when I click this button, I want to save the password in a .txt file. Who can write such code.
      My Qt version is 5.14

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      @Qwerty123098 said in help write code:

      Who can write such code.

      You can! See https://doc.qt.io/qt-5/qfile.html (there is a paragraph that starts with "To write text")

      P.S.

      I want to save the password in a .txt file

      usually you don't save the password but a QCryptographicHash of the password for security reasons

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      Q 1 Reply Last reply
      6
      • VRoninV VRonin

        @Qwerty123098 said in help write code:

        Who can write such code.

        You can! See https://doc.qt.io/qt-5/qfile.html (there is a paragraph that starts with "To write text")

        P.S.

        I want to save the password in a .txt file

        usually you don't save the password but a QCryptographicHash of the password for security reasons

        Q Offline
        Q Offline
        Qwerty123098
        wrote on last edited by Qwerty123098
        #3

        no, in the sense of the text that is written in lineEdit to save in a .txt file in a directory by clicking on the "Save file" button

        1 Reply Last reply
        0
        • Q Qwerty123098

          I created lineEdit, button, and password generator engine , password is generated in lineEdit, and so, when I click this button, I want to save the password in a .txt file. Who can write such code.
          My Qt version is 5.14

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by Pl45m4
          #4

          @Qwerty123098

          Use your lineEdit->text() , convert it to a QByteArray and then generate a QCryptographicHash (like @VRonin mentioned above) from it. Afterwards you can store this in your txt-file.

          To do so, you open your file or create a new one and write your array to file.

          QFile file("PATH/pw.txt");
          if (file.open(QIODevice::WriteOnly)) 
          {
          	file.write(YourByteArray);
          	file.close();
          }
          

          @Qwerty123098 said in help write code:

          text that is written in lineEdit save in a .txt file in a directory

          Just normal text you dont need to encrypt or hash, but you dont want to do this with real passwords and save them as plain text in a txt-file on your drive.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          Q 1 Reply Last reply
          5
          • Pl45m4P Pl45m4

            @Qwerty123098

            Use your lineEdit->text() , convert it to a QByteArray and then generate a QCryptographicHash (like @VRonin mentioned above) from it. Afterwards you can store this in your txt-file.

            To do so, you open your file or create a new one and write your array to file.

            QFile file("PATH/pw.txt");
            if (file.open(QIODevice::WriteOnly)) 
            {
            	file.write(YourByteArray);
            	file.close();
            }
            

            @Qwerty123098 said in help write code:

            text that is written in lineEdit save in a .txt file in a directory

            Just normal text you dont need to encrypt or hash, but you dont want to do this with real passwords and save them as plain text in a txt-file on your drive.

            Q Offline
            Q Offline
            Qwerty123098
            wrote on last edited by
            #5

            @Pl45m4 save by clicking on the "Save file" button

            Pl45m4P 1 Reply Last reply
            0
            • Q Qwerty123098

              @Pl45m4 save by clicking on the "Save file" button

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by
              #6

              @Qwerty123098

              Connect your button (clicked signal) with your slot / function and put your code there.
              https://doc.qt.io/qt-5/signalsandslots.html


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              1 Reply Last reply
              5
              • Q Offline
                Q Offline
                Qwerty123098
                wrote on last edited by
                #7

                Thank you

                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