PDA

View Full Version : Standard Exit button usage



prophet23
9th November 2011, 11:54
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[])
{
QApplication app(argc, argv);
myQtApp *dialog = new myQtApp;

dialog->show();
return app.exec();
}


The application is as follows:


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() << "");

}


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?

stampede
9th November 2011, 12:17
QWidget::closeEvent