I am new to qt. i have an application which have several forms.
i am trying to select the specific form from main.cpp, but it just flickered the form. But i am getting th
The problem is that w in both cases have a limited scope inside the "if" so they are destroyed instantly. One solution is to use pointers managing dynamic memory, for example using QScopedPointer:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QScopedPointer<QWidget> w;
int theme = 2;
if(theme == 1)
{
w.reset(new Design1);
}
else{
w.reset(new Dialog);
}
if(w){
w->showMaximized();
w->show();
}
return a.exec();
}