QGIS API Documentation  2.99.0-Master (cd0ba91)
qgsrunprocess.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrunprocess.h
3 
4  A class that runs an external program
5 
6  -------------------
7  begin : Jan 2005
8  copyright : (C) 2005 by Gavin Macaulay
9  email : gavin at macaulay dot co dot nz
10  ***************************************************************************/
11 
12 /***************************************************************************
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  ***************************************************************************/
20 
21 #ifndef QGSRUNPROCESS_H
22 #define QGSRUNPROCESS_H
23 
24 #include <QObject>
25 #include <QProcess>
26 
27 #include "qgis_core.h"
28 #include "qgis_sip.h"
29 
30 class QgsMessageOutput;
31 
38 class CORE_EXPORT QgsRunProcess: public QObject SIP_NODEFAULTCTORS
39 {
40  Q_OBJECT
41 
42  public:
43  // This class deletes itself, so to ensure that it is only created
44  // using new, the Named Consturctor Idiom is used, and one needs to
45  // use the create() static function to get an instance of this class.
46 
47  // The action argument contains string with the command.
48  // If capture is true, the standard output and error from the process
49  // will be sent to QgsMessageOutput - usually a dialog box.
50  static QgsRunProcess *create( const QString &action, bool capture ) SIP_FACTORY
51  { return new QgsRunProcess( action, capture ); }
52 
53  public slots:
54  void stdoutAvailable();
55  void stderrAvailable();
56  void processError( QProcess::ProcessError );
57  void processExit( int, QProcess::ExitStatus );
58  void dialogGone();
59 
60  private:
61  QgsRunProcess( const QString &action, bool capture ) SIP_FORCE;
63 
64  // Deletes the instance of the class
65  void die();
66 
67  QProcess *mProcess = nullptr;
68  QgsMessageOutput *mOutput = nullptr;
69  QString mCommand;
70 };
71 
72 #endif
#define SIP_FORCE
Definition: qgis_sip.h:124
#define SIP_FACTORY
Definition: qgis_sip.h:69
#define SIP_NODEFAULTCTORS
Definition: qgis_sip.h:94
A class that executes an external program/script.
Definition: qgsrunprocess.h:38
static QgsRunProcess * create(const QString &action, bool capture)
Definition: qgsrunprocess.h:50
Interface for showing messages from QGIS in GUI independent way.