Results 1 to 4 of 4

Thread: QTcreator - Check 1 process is running ?

  1. #1
    Join Date
    Mar 2010
    Posts
    92
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default QTcreator - Check 1 process is running ?

    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

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTcreator - Check 1 process is running ?

    Connect the relevent signals from QProcess

  3. #3
    Join Date
    Mar 2010
    Posts
    92
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QTcreator - Check 1 process is running ?

    Quote Originally Posted by fatjuicymole View Post
    Connect the relevent signals from QProcess
    how to connect ?

  4. #4
    Join Date
    Mar 2010
    Posts
    92
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QTcreator - Check 1 process is running ?

    Quote Originally Posted by fatjuicymole View Post
    Connect the relevent signals from QProcess
    Qt Code:
    1. #include "widgetcheckprocess.h"
    2. #include <QtGui/QApplication>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. WidgetCheckProcess w;
    8. w.show();
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 
    WIDGETCHECKPROCESS.h

    Qt Code:
    1. #ifndef WIDGETCHECKPROCESS_H
    2. #define WIDGETCHECKPROCESS_H
    3.  
    4. #include <QtGui/QMainWindow>
    5. #include "ui_widgetcheckprocess.h"
    6. #include <QProcess>
    7. class WidgetCheckProcess : public QMainWindow
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. QProcess *qpProcess;
    13. WidgetCheckProcess(QWidget *parent = 0, Qt::WFlags flags = 0);
    14. ~WidgetCheckProcess();
    15. public slots:
    16. void SlotDetectFinish(int *exitCode, QProcess::ExitStatus *exitSatus);
    17. void StartProcess(QString qsProcessPath);
    18. signals:
    19. void finished(int exitCode, QProcess::ExitStatus exitStatus);
    20. private:
    21. Ui::WidgetCheckProcessClass ui;
    22. };
    23.  
    24. #endif // WIDGETCHECKPROCESS_H
    To copy to clipboard, switch view to plain text mode 



    WIDGETCHECKPROCESS.cpp

    Qt Code:
    1. #include "widgetcheckprocess.h"
    2. #include <QMessageBox>
    3. WidgetCheckProcess::WidgetCheckProcess(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags)
    4. {
    5. ui.setupUi(this);
    6. StartProcess("D:/s.exe");
    7. connect(qpProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(SlotDetectFinish(int, QProcess::ExitStatus)));
    8. }
    9. WidgetCheckProcess::~WidgetCheckProcess()
    10. {
    11. }
    12. void WidgetCheckProcess::StartProcess(QString qsProcessPath)
    13. {
    14. qpProcess->start(qsProcessPath);
    15. }
    16. void WidgetCheckProcess::SlotDetectFinish(int *exitCode, QProcess::ExitStatus *exitSatus)
    17. {
    18. QMessageBox msgBox;
    19. msgBox.setText("Process Run Finnish");
    20. msgBox.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. How to check if a program is running?
    By raphaelf in forum Newbie
    Replies: 16
    Last Post: 30th April 2010, 15:59
  2. Replies: 2
    Last Post: 5th November 2009, 03:02
  3. Destroyed while process is still running
    By qtzcute in forum Qt Programming
    Replies: 5
    Last Post: 23rd July 2009, 08:26
  4. Connecting with QProcess to an already running process
    By high_flyer in forum Qt Programming
    Replies: 7
    Last Post: 26th November 2007, 10:31
  5. Check wheter a process is running
    By Lele in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2006, 12:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.