PDA

View Full Version : main.cpp performing action after mainwindow.cpp close



codersquirrel
29th February 2016, 13:50
I have the main and mainwindows cpp, yes, i need to have both.
How do i do to main.cpp performing a action only after mainwindow.cpp is closed?

I have tried
ConfigCamera c;
c.show();
c.CameraQuantidade(CAMERAS);
c.close();
std::cout <<"i'm here" <<std::endl;

and
ConfigCamera c;
c.show();
c.CameraQuantidade(CAMERAS);
while(!c.isClosed) {
}
std::cout <<"i'm here" <<std::endl;

but they haven't work.

How should i do this?

anda_skoa
29th February 2016, 14:19
You could emit a signal from widget's closeEvent() handler and connect a slot to that.

Or, if it is a dialog, run it with exec() and put your code after it returns.

Or, if this is the main window, put your code after exec() of the QApplication has returned.

Cheers,
_