Reputation: 63
I am creating a program that requires a form to be opened, and the previous to be closed on a push button click. My current problem is that when I click the button the new form is shown for a millisecond then disappears.
void mainMenu::on_mainLoginB_clicked()
{
logIn objlogIn;
objlogIn.show();
}
void mainMenu::on_mainExitB_clicked()
{
exit(1);
}
here is my header file
private slots:
void on_mainLoginB_clicked();
void on_mainExitB_clicked();
private:
Ui::mainMenu *ui;
};
Upvotes: 0
Views: 72
Reputation: 14865
objLogIn
is declared in the scope of the SLOT, and for this reason, deleted when the function return.
Remember that QT, like most user interfaces works with an event (message) loop, so functions like show()
do not block: they immediately return and it is the event loop managing it further.
For solving this issue:
Upvotes: 3