#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtGui>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void openProcess();
void readResult(int exitCode);
private:
QProcess *p;
};
#endif // MAINWINDOW_H
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
p = new QProcess(this);
QPushButton *bt = new QPushButton("execute notepad", this);
connect(bt, SIGNAL(clicked()), this, SLOT(openProcess()));
}
MainWindow::~MainWindow()
{
}
void MainWindow::openProcess()
{
p->start("cmd.exe", QStringList() << "/c" << "dir");
connect(p, SIGNAL(finished(int)), this, SLOT(readResult(int)));
}