QT read/write text file from QLine Edit when Click QPushButton
-
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.
-
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.
@TheCeylann Use https://doc.qt.io/qt-5/qfile.html to read/write files.
Keep in mind - storing passwords unencrypted is dangerous! -
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.
Consider using
QCryprographicHash, store the hash in your file and compare the hashes when the user enters a password.@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.