Hello,

I would like to present a popup at the beginning of my program, which let the user chose between 2 modes.
If the user makes his choice, then a new window shall be opened. Unfortunately, bot the popup and another window disappear after clicking on one of the pushbuttons. Can you tell me what is the reason and how to deal with this problem (see my code below)?
Thank you

best regards,

Vitali

Qt Code:
  1. #include <QApplication>
  2. #include <QPushButton>
  3. #include <QMessageBox>
  4. #include <mainframe.h>
  5. #include "dialog_start.h"
  6. #include "OscillationGRN.h"
  7.  
  8. int main(int argc, char **argv)
  9. {
  10.  
  11. QApplication app(argc, argv);
  12.  
  13. // first appears a popup, which will offer to the user 2 different kinds of problems
  14. QMessageBox msgBox;
  15. QPushButton *OscillationButton = msgBox.addButton("Sustained Oscillation", QMessageBox::ActionRole);
  16. QPushButton *BenchmarkButton = msgBox.addButton("constrained Problems",QMessageBox::ActionRole);
  17.  
  18. msgBox.exec();
  19.  
  20. if(msgBox.clickedButton() == BenchmarkButton){ // if the user decide to cope with optimization of constrained benchmark problems
  21.  
  22. mainFrame mainWind;
  23.  
  24. // execute the initialization dialog
  25. dialogStart start(0, &mainWind);
  26. start.show(); // the mainWindow will be opened after the user click on START button within dialogStart
  27. msgBox.hide();
  28. }
  29. else if(msgBox.clickedButton() == OscillationButton){ // if the user decide to cope with generation of oscillation by means of Gene Regulatory Networks
  30. OscillationGRN evoGRN;
  31. evoGRN.show();
  32. msgBox.hide();
  33. }
  34. return app.exec();
  35.  
  36. exit(EXIT_SUCCESS);
  37.  
  38. }
To copy to clipboard, switch view to plain text mode