Answer of exercise: Qt hide and show #1 is the answer of the exercise Qt hide and show #1.
The uninteded behavior is coded in main:
#include <QtGui/QApplication> #include "firstdialog.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); FirstDialog w; w.exec(); }
I think that this means, that at the moment when FirstDialog is hidden (for showing the second dialog) and the second dialog closes, FirstDialog::exec finishes with an error code of zero.
Instead, I want that that moment is bridged until the first dialog closes. In that case main should be:
#include <QtGui/QApplication> #include "firstdialog.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); FirstDialog w; w.show(); a.exec(); }