how to show and hide frames?
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
Code:
#include <QApplication>
#include <QPushButton>
#include <QMessageBox>
#include <mainframe.h>
#include "dialog_start.h"
#include "OscillationGRN.h"
int main(int argc, char **argv)
{
// first appears a popup, which will offer to the user 2 different kinds of problems
msgBox.exec();
if(msgBox.clickedButton() == BenchmarkButton){ // if the user decide to cope with optimization of constrained benchmark problems
mainFrame mainWind;
// execute the initialization dialog
dialogStart start(0, &mainWind);
start.show(); // the mainWindow will be opened after the user click on START button within dialogStart
msgBox.hide();
}
else if(msgBox.clickedButton() == OscillationButton){ // if the user decide to cope with generation of oscillation by means of Gene Regulatory Networks
OscillationGRN evoGRN;
evoGRN.show();
msgBox.hide();
}
return app.exec();
exit(EXIT_SUCCESS);
}
Re: how to show and hide frames?
Probably because you are declaring the windows inside the if else condition.
Quote:
mainFrame mainWind; and OscillationGRN evoGRN;
Try declaring them above the if condition on a larger scope :)
Re: how to show and hide frames?
Yes, you are right, aamer4yu. Thank you
Now it works with the following code:
Code:
#include <QApplication>
#include <QPushButton>
#include <QMessageBox>
#include <mainframe.h>
#include "dialog_start.h"
#include "OscillationGRN.h"
#include <iostream>
int main(int argc, char **argv)
{
// first appears a popup, which will offer to the user 2 different kinds of problems
msgBox.setText("Which one of the optimization problems do you want to execute?");
msgBox.setInformativeText("Make your choice by clicking on button.");
msgBox.exec();
mainFrame mainWind; // build Main Window
dialogStart start(0, &mainWind); // build Initialization window
OscillationGRN evoGRN; // build OscillationGRN window
if(msgBox.clickedButton() == BenchmarkButton){ // if the user decide to cope with optimization of constrained benchmark problems
start.show(); // the mainWindow will be opened after the user click on START button within dialogStart
}
else if(msgBox.clickedButton() == OscillationButton){ // if the user decide to cope with generation of oscillation by means of Gene Regulatory Networks
evoGRN.show();
}
return app.exec();
exit(EXIT_SUCCESS);
}