PDA

View Full Version : how to restart the MainWindow?



d@nyal
2nd May 2010, 20:09
Hi everybody,

You know in main function of a default GUI application, a new object of kind MainWindow be created.

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// make a new MainWindow object :
MainWindow w;
w.show();
return a.exec();
}


I am looking for a way to restart the the MainWindow, "controlled inside of MainWindow object".
for a example if I click on a bottun on ui, the window would restart and start from the begining...

Can you help me?

squidge
2nd May 2010, 22:09
You could have MainWindow on the heap, have the buttons terminating the event loop and then delete and recreate the MainWindow object inside your main function, but I'm not sure why you would want to.

The purpose of this is ?

d@nyal
3rd May 2010, 03:51
You could have MainWindow on the heap, have the buttons terminating the event loop and then delete and recreate the MainWindow object inside your main function,
Thanks !
Would you explain more? (if possible with simple code)



but I'm not sure why you would want to.

The purpose of this is ?

I want to restart it, because there are several processes iin my application that I think they slacken the program.