Standard Exit button
Hello Qt experts,
I have the application with .ui file specified in Qt Designer. The application starts several processes during execution. Question is about their termination.
I have already manage to close them with the button I created.
However I would like to do it by clicking standard Exit button [X]. How can I use that button to close gracefully all the active processes?
The main function is a standard one:
#include <QApplication>
#include "myqtapp.h"
int main(int argc, char *argv[])
{
myQtApp *dialog = new myQtApp;
dialog->show();
return app.exec();
}
#include <QApplication>
#include "myqtapp.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
myQtApp *dialog = new myQtApp;
dialog->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
The application is as follows:
{
setupUi(this); // this sets up GUI
RWS_start(); // this function starts process/processes
connect( _quit, SIGNAL( clicked() ), this, SLOT( quit() ) );
}
myQtApp::~myQtApp()
{
}
void myQtApp::RWS_start(){
QString Path
= "C:\\Robostacker\\RWS\\RobWorkStudio.exe";
}
myQtApp::myQtApp(QWidget *parent)
{
setupUi(this); // this sets up GUI
RWS_start(); // this function starts process/processes
connect( _quit, SIGNAL( clicked() ), this, SLOT( quit() ) );
}
myQtApp::~myQtApp()
{
}
void myQtApp::RWS_start(){
QProcess *process = new QProcess(this);
QString Path = "C:\\Robostacker\\RWS\\RobWorkStudio.exe";
process->start(Path, QStringList() << "");
}
To copy to clipboard, switch view to plain text mode
It would be interesting to add the Window which ask user if is sure that want to close the application.
The Window should appear after click the standard Exit button [X].
Any tips or even better the examples to solve that best?
Bookmarks