I was making a test program where the MainWindow serves as a login screen. User types in a username and password. If they match what the string is assigned to, then the Dialog appears. If it fails, a QMessageBox appears instead.
What my issue is when I want the Dialog to appear (the main program), I want the Login page to disappear. The Command close(); would just close everything.
Here is the code for the MainWindow.cpp (The Dialog is referenced in the header as a POINTER called mDialog)
void MainWindow::on_pushButton_clicked()
{
if (ui->lineEdit->text() == username)
{
if (ui->lineEdit_2->text() == password)
{
//This is where the Dialog appears
mDialog= new MyDialog(this);
mDialog->show();
}
}
else if (ui->lineEdit->text() != username || ui->lineEdit->text() ==NULL)
{
if (ui->lineEdit_2->text() != password || ui->lineEdit_2->text() == NULL)
{
QMessageBox::warning(this, "Error", "The username or password is incorrect.");
}
}
}
Here is the code for the main.cpp
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}