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. QT read/write text file from QLine Edit when Click QPushButton

QT read/write text file from QLine Edit when Click QPushButton

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

    I need to write new password to text file and read from text file How Can I do that?

    void SecondWindow::on_pushButton_8_clicked()
    {
    
      
    
    \\I  need read old password  from password.txt and write new one to text file
    
    
        }
    

    void MainWindow::on_userLoginBtn_clicked()
    {
    \ I need read text fıle here
    QString username = ui->usernameBox->text();
    QString password = ui->passwordBox->text();

    if (username == "test"   && password ==  "test"  ) {
        QMessageBox::information(this, "Giriş","Giriş Başarılı" );
        hide();
        secondWindow = new SecondWindow(this);
        secondWindow ->show();
    }
    

    }

    How Can I do that. I m just started 2 days ago to qt and C++. Sorry for my information less.

    jsulmJ Pl45m4P 2 Replies Last reply
    0
    • T TheCeylann

      I need to write new password to text file and read from text file How Can I do that?

      void SecondWindow::on_pushButton_8_clicked()
      {
      
        
      
      \\I  need read old password  from password.txt and write new one to text file
      
      
          }
      

      void MainWindow::on_userLoginBtn_clicked()
      {
      \ I need read text fıle here
      QString username = ui->usernameBox->text();
      QString password = ui->passwordBox->text();

      if (username == "test"   && password ==  "test"  ) {
          QMessageBox::information(this, "Giriş","Giriş Başarılı" );
          hide();
          secondWindow = new SecondWindow(this);
          secondWindow ->show();
      }
      

      }

      How Can I do that. I m just started 2 days ago to qt and C++. Sorry for my information less.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @TheCeylann Use https://doc.qt.io/qt-5/qfile.html to read/write files.
      Keep in mind - storing passwords unencrypted is dangerous!

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • T TheCeylann

        I need to write new password to text file and read from text file How Can I do that?

        void SecondWindow::on_pushButton_8_clicked()
        {
        
          
        
        \\I  need read old password  from password.txt and write new one to text file
        
        
            }
        

        void MainWindow::on_userLoginBtn_clicked()
        {
        \ I need read text fıle here
        QString username = ui->usernameBox->text();
        QString password = ui->passwordBox->text();

        if (username == "test"   && password ==  "test"  ) {
            QMessageBox::information(this, "Giriş","Giriş Başarılı" );
            hide();
            secondWindow = new SecondWindow(this);
            secondWindow ->show();
        }
        

        }

        How Can I do that. I m just started 2 days ago to qt and C++. Sorry for my information less.

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

        Consider using QCryprographicHash, store the hash in your file and compare the hashes when the user enters a password.

        • https://doc.qt.io/qt-5/qcryptographichash.html

        @TheCeylann said in QT read/write text file from QLine Edit when Click QPushButton:

        hide();
        secondWindow = new SecondWindow(this);
        secondWindow ->show();

        Also, this might crash or exit your app since you hide the last visible widget/window.

        • https://doc.qt.io/qt-5/qguiapplication.html#quitOnLastWindowClosed-prop

        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
        3

        • Login

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