When i click a button i need the control to go back to main.cpp. In main.cpp it can be to any functions.
-
I have a mainwindow.cpp file and a main.cpp file
1] in mainwindow.cpp
/
headers
/
MainWindow::MainWindow() //Constructor
{
I have connect(ui->finish, SIGNAL(clicked()), ?, SLOT(?))
}
The problem is i need this slot to go to a method in main.cpp
How can i do this?For ex
main.cpp
int main(int argc, char *argv[])
{int s = GUI_Init(argc, argv);
// on_Finish_clicked
I need my slot to come here when i click a button as i mentioned a connect() in mainwindow.cpp qInfo() << "In Main after GUI Init";
return 0;
}int GUI_Init(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
qInfo() <<"Begining UI";
w.show();
qInfo() <<"End UI";
return a.exec();
} -
Connect your slot to QCoreApplication::quit() slot.
-
Calling quit() will end the event loop, thus your call in GUI_Init() will return:
return a.exec();
And that means you'll be back in main.cpp in your case. -
Just write a function in your main.cpp and connect to it as shown in http://wiki.qt.io/New_Signal_Slot_Syntax ("New: connecting to simple function")