QgsPythonRunner class

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?

Public static functions

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

Constructors, destructors, conversion operators

QgsPythonRunner() protected defaulted
Protected constructor: can be instantiated only from children.

Function documentation

static void QgsPythonRunner::setInstance(QgsPythonRunner* runner)

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.