I want to create an inspection process A is always a process B, if B dies, the process will restart the process A process, I have to do?
build on QT not use windows API
Printable View
I want to create an inspection process A is always a process B, if B dies, the process will restart the process A process, I have to do?
build on QT not use windows API
Connect the relevent signals from QProcess
WIDGETCHECKPROCESS.hCode:
#include "widgetcheckprocess.h" #include <QtGui/QApplication> int main(int argc, char *argv[]) { WidgetCheckProcess w; w.show(); return a.exec(); }
Code:
#ifndef WIDGETCHECKPROCESS_H #define WIDGETCHECKPROCESS_H #include <QtGui/QMainWindow> #include "ui_widgetcheckprocess.h" #include <QProcess> { Q_OBJECT public: QProcess *qpProcess; ~WidgetCheckProcess(); public slots: signals: private: Ui::WidgetCheckProcessClass ui; }; #endif // WIDGETCHECKPROCESS_H
WIDGETCHECKPROCESS.cpp
Code:
#include "widgetcheckprocess.h" #include <QMessageBox> WidgetCheckProcess::WidgetCheckProcess(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags) { ui.setupUi(this); StartProcess("D:/s.exe"); } WidgetCheckProcess::~WidgetCheckProcess() { } { qpProcess->start(qsProcessPath); } { QMessageBox msgBox; msgBox.setText("Process Run Finnish"); msgBox.exec(); }