Every widget constructor should never block the main message loop!
The main message loop looks usually like this:
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
MainWindow w(nullptr);
w.show();
int r = a.exec();
return r
}
In your case your MainWindow
ctor never returns, so w.show()
is never called and a.exec()
(main messgae loop) is never executed.
Not only blocking may be a problem in main window ctor, but also signals that are generated before main message loop is executed gets never raised. For an example establishment of an TCP/IP connection within main window ctor will never raise the connected()
signal and associated slots. *1
At least if the creation of the main window is before the main message loop is executed like in 99% the cases.
solved Window doesn’t appear when using while loop