View Full Version : QTcreator - Check 1 process is running ?
nhs_0702
28th April 2010, 12:35
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
squidge
28th April 2010, 13:55
Connect the relevent signals from QProcess
nhs_0702
29th April 2010, 11:06
Connect the relevent signals from QProcess
how to connect ?
nhs_0702
29th April 2010, 11:35
Connect the relevent signals from QProcess
#include "widgetcheckprocess.h"
#include <QtGui/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
WidgetCheckProcess w;
w.show();
return a.exec();
}
WIDGETCHECKPROCESS.h
#ifndef WIDGETCHECKPROCESS_H
#define WIDGETCHECKPROCESS_H
#include <QtGui/QMainWindow>
#include "ui_widgetcheckprocess.h"
#include <QProcess>
class WidgetCheckProcess : public QMainWindow
{
Q_OBJECT
public:
QProcess *qpProcess;
WidgetCheckProcess(QWidget *parent = 0, Qt::WFlags flags = 0);
~WidgetCheckProcess();
public slots:
void SlotDetectFinish(int *exitCode, QProcess::ExitStatus *exitSatus);
void StartProcess(QString qsProcessPath);
signals:
void finished(int exitCode, QProcess::ExitStatus exitStatus);
private:
Ui::WidgetCheckProcessClass ui;
};
#endif // WIDGETCHECKPROCESS_H
WIDGETCHECKPROCESS.cpp
#include "widgetcheckprocess.h"
#include <QMessageBox>
WidgetCheckProcess::WidgetCheckProcess(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags)
{
ui.setupUi(this);
StartProcess("D:/s.exe");
connect(qpProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(SlotDetectFinish(int, QProcess::ExitStatus)));
}
WidgetCheckProcess::~WidgetCheckProcess()
{
}
void WidgetCheckProcess::StartProcess(QString qsProcessPath)
{
qpProcess->start(qsProcessPath);
}
void WidgetCheckProcess::SlotDetectFinish(int *exitCode, QProcess::ExitStatus *exitSatus)
{
QMessageBox msgBox;
msgBox.setText("Process Run Finnish");
msgBox.exec();
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.