Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
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
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?
int main(int argc, char *argv)
int s = GUI_Init(argc, argv);
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";
int GUI_Init(int argc, char *argv)
QApplication a(argc, argv);
qInfo() <<"Begining UI";
qInfo() <<"End UI";
Connect your slot to QCoreApplication::quit() slot.
Will this take my control back to the main.cpp? I may have a method in main.cpp which i need to call when the finish button is clicked.
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.
mvuori last edited by
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")
Thank you all, the issue is solved.