QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Static Public Member Functions | Protected Member Functions | Static Protected Attributes | List of all members
QgsPythonRunner Class Referenceabstract

Utility class for running python commands from various parts of QGIS. More...

#include <qgspythonrunner.h>

Static Public Member Functions

static bool eval (const QString &command, QString &result)
 Eval a python statement. More...
 
static bool isValid ()
 Returns true if the runner has an instance (and thus is able to run commands) More...
 
static bool run (const QString &command, const QString &messageOnError=QString())
 Execute a python statement. More...
 
static void setInstance (QgsPythonRunner *runner)
 Assign an instance of python runner so that run() can be used. More...
 

Protected Member Functions

 QgsPythonRunner ()
 Protected constructor: can be instantiated only from children. More...
 
virtual ~QgsPythonRunner ()
 
virtual bool evalCommand (QString command, QString &result)=0
 
virtual bool runCommand (QString command, QString messageOnError=QString())=0
 

Static Protected Attributes

static QgsPythonRunnermInstance = nullptr
 

Detailed Description

Utility class for running python commands from various parts of QGIS.

There is no direct python support in the core library, so it is expected that application with python support creates a subclass that implements pure virtual function(s) during the initialization. The static methods will then work as expected.

Added in QGIS v?

Definition at line 29 of file qgspythonrunner.h.

Constructor & Destructor Documentation

◆ QgsPythonRunner()

QgsPythonRunner::QgsPythonRunner ( )
protected

Protected constructor: can be instantiated only from children.

Definition at line 64 of file qgspythonrunner.cpp.

◆ ~QgsPythonRunner()

QgsPythonRunner::~QgsPythonRunner ( )
protectedvirtual

Definition at line 68 of file qgspythonrunner.cpp.

Member Function Documentation

◆ eval()

bool QgsPythonRunner::eval ( const QString command,
QString result 
)
static

Eval a python statement.

Definition at line 42 of file qgspythonrunner.cpp.

◆ evalCommand()

virtual bool QgsPythonRunner::evalCommand ( QString  command,
QString result 
)
protectedpure virtual

◆ isValid()

bool QgsPythonRunner::isValid ( )
static

Returns true if the runner has an instance (and thus is able to run commands)

Definition at line 23 of file qgspythonrunner.cpp.

◆ run()

bool QgsPythonRunner::run ( const QString command,
const QString messageOnError = QString() 
)
static

Execute a python statement.

Definition at line 28 of file qgspythonrunner.cpp.

◆ runCommand()

virtual bool QgsPythonRunner::runCommand ( QString  command,
QString  messageOnError = QString() 
)
protectedpure virtual

◆ setInstance()

void QgsPythonRunner::setInstance ( QgsPythonRunner runner)
static

Assign an instance of python runner so that run() can be used.

This method should be called during app initialization. Takes ownership of the object, deletes previous instance.

Definition at line 55 of file qgspythonrunner.cpp.

Member Data Documentation

◆ mInstance

QgsPythonRunner * QgsPythonRunner::mInstance = nullptr
staticprotected

Definition at line 57 of file qgspythonrunner.h.


The documentation for this class was generated from the following files: