I am writing a login window in Qt.
When the users clicks on OK, it should close the login window, show a “Connecting to server…” Widget, and open the main window once the connecttoserver method has done its job.
However, the widget appears only when the main window is shown, and disappears immediately (it shouldn’t even close!)
How do I solve this issue ?
void LoginWindow::blah()
{
close();
QWidget widget;
widget.show();
//calls to the "connecttoserver method"
Main *main = new Main(student->getInfo()[0], student->getInfo()[1], student->getInfo()[2], view);
main->show();
}
}
QWidget is declared as an automatic on the stack so it is destroyed when the method returns. You want to declare it on the heap instead: