Class: QgsApplication

Extends QApplication to provide access to QGIS specific resources such as theme paths, database paths etc.

This is a subclass of QApplication and should be instantiated in place of QApplication. Most methods are static in keeping with the design of QApplication.

This class hides platform-specific path information and provides a portable way of referencing specific files and directories. Ideally, hard-coded paths should appear only here and not in other modules so that platform-conditional code is minimized and paths are easier to change due to centralization.

Class Hierarchy

Inheritance diagram of qgis.core.QgsApplication

Base classes

QApplication

QGuiApplication

QCoreApplication

QObject

class qgis.core.QgsApplication[source]

Bases: QApplication

__init__(argv: List, GUIenabled: bool, profileFolder: str | None = '', platformName: str | None = '')

Constructor for QgsApplication.

Parameters:
  • argv (List) – command line arguments

  • GUIenabled (bool) – set to True if a GUI application is required, or False for a console only application

  • profileFolder (Optional[str] = '') – optional string representing the profile to load at startup

  • platformName (Optional[str] = '') – the QGIS platform name, e.g., “desktop”, “server”, “qgis_process” or “external” (for external CLI scripts)

CapturePoint = 4
CrossHair = 3
class Cursor

Bases: int

Identify = 2
NDR = 1
QGIS_APPLICATION_NAME = 'QGIS3'
QGIS_ORGANIZATION_DOMAIN = 'qgis.org'
QGIS_ORGANIZATION_NAME = 'QGIS'
Qt = 0
Sampler = 6
Select = 5
class StyleSheetType

Bases: int

WebBrowser = 1
XDR = 0
ZoomIn = 0
ZoomOut = 1
static absolutePathToRelativePath(apath: str | None, targetPath: str | None) str[source]

Converts absolute path to path relative to target

Parameters:
  • apath (Optional[str])

  • targetPath (Optional[str])

Return type:

str

static actionScopeRegistry() QgsActionScopeRegistry | None[source]

Returns the action scope registry.

Return type:

Optional[QgsActionScopeRegistry]

static activeThemePath() str[source]

Returns the path to the currently active theme directory.

Return type:

str

static annotationItemRegistry() QgsAnnotationItemRegistry | None[source]

Returns the application’s annotation item registry, used for annotation item types.

Added in version 3.16.

Return type:

Optional[QgsAnnotationItemRegistry]

static appIconPath() str[source]

Gets application icon

Return type:

str

static applicationFullName() str[source]

Returns the QGIS application full name.

It can be defined by the environment variable QGIS_APPLICATION_FULL_NAME or the /qgis/application_full_name in the QGIS config file.

By default it is equal to platform()

See also

platform()

Added in version 3.30.

Return type:

str

static applyGdalSkippedDrivers()[source]

Apply the skipped drivers list to gdal

See also

skipGdalDriver()

static authConfigurationStorageRegistry() QgsAuthConfigurationStorageRegistry | None[source]

Returns the application’s authentication configuration storage registry

Added in version 3.40.

Return type:

Optional[QgsAuthConfigurationStorageRegistry]

static authManager() QgsAuthManager | None[source]

Returns the application’s authentication manager instance

Note

this can be None if called before initQgis

See also

initQgis()

Return type:

Optional[QgsAuthManager]

static authorsFilePath() str[source]

Returns the path to the authors file.

Return type:

str

static bookmarkManager() QgsBookmarkManager | None[source]

Returns the application’s bookmark manager, used for storing installation-wide bookmarks.

Added in version 3.10.

Return type:

Optional[QgsBookmarkManager]

static buildOutputPath() str[source]

Returns path to the build output directory. Valid only when running from build directory

Return type:

str

static buildSourcePath() str[source]

Returns path to the source directory. Valid only when running from build directory

Return type:

str

static calloutRegistry() QgsCalloutRegistry | None[source]

Returns the application’s callout registry, used for managing callout types.

Added in version 3.10.

Return type:

Optional[QgsCalloutRegistry]

static classificationMethodRegistry() QgsClassificationMethodRegistry | None[source]

Returns the application’s classification methods registry, used in graduated renderer

Added in version 3.10.

Return type:

Optional[QgsClassificationMethodRegistry]

collectTranslatableObjects(self, translationContext: QgsTranslationContext | None)[source]

Emits the signal to collect all the strings of .qgs to be included in ts file

Added in version 3.4.

Parameters:

translationContext (Optional[QgsTranslationContext])

static colorSchemeRegistry() QgsColorSchemeRegistry | None[source]

Returns the application’s color scheme registry, used for managing color schemes.

Return type:

Optional[QgsColorSchemeRegistry]

static connectionRegistry() QgsConnectionRegistry | None[source]

Returns the application’s connection registry, used for managing saved data provider connections.

Added in version 3.14.

Return type:

Optional[QgsConnectionRegistry]

static contributorsFilePath() str[source]

Returns the path to the contributors file. Contributors are people who have submitted patches but don’t have commit access.

Return type:

str

static coordinateReferenceSystemRegistry() QgsCoordinateReferenceSystemRegistry | None[source]

Returns the application’s coordinate reference system (CRS) registry, which handles known CRS definitions (including user-defined CRSes).

Added in version 3.18.

Return type:

Optional[QgsCoordinateReferenceSystemRegistry]

static createDatabase(errorMessage: str | None | None = '') bool[source]

initialize qgis.db

Parameters:

errorMessage (Optional[Optional[str]] = '')

Return type:

bool

static createThemeFolder() bool[source]

Create the users theme folder

Return type:

bool

static customVariables() Dict[str, Any][source]

Custom expression variables for this application. This does not include generated variables (like system name, user name etc.)

Return type:

Dict[str, Any]

signal customVariablesChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

static dataItemProviderRegistry() QgsDataItemProviderRegistry | None[source]

Returns the application’s data item provider registry, which keeps a list of data item providers that may add items to the browser tree.

Return type:

Optional[QgsDataItemProviderRegistry]

static databaseQueryLog() QgsDatabaseQueryLog | None[source]

Returns the database query log.

Added in version 3.24.

Return type:

Optional[QgsDatabaseQueryLog]

static defaultStyleModel() QgsStyleModel | None[source]

Returns a shared QgsStyleModel containing the default style library (see QgsStyle.defaultStyle()).

Using this shared model instead of creating a new QgsStyleModel improves performance.

Added in version 3.10.

Return type:

Optional[QgsStyleModel]

static defaultStylePath() str[source]

Returns the path to default style (works as a starting point).

Return type:

str

static defaultThemePath() str[source]

Returns the path to the default theme directory.

Return type:

str

static defaultThemesFolder() str[source]

Returns the path to default themes folder from install (works as a starting point).

Return type:

str

static deferredSkippedGdalDrivers() List[str][source]

Returns the list of gdal drivers that have been disabled in the current session, and thus, for safety, should not be disabled right now, but at the next application restart.

Added in version 3.10.

Return type:

List[str]

static donorsFilePath() str[source]

Returns the path to the donors file.

Return type:

str

static endian() QgsApplication.endian_t[source]

Returns whether this machine uses big or little endian

Return type:

QgsApplication.endian_t

class endian_t

Bases: int

virtual event(self, event: QEvent | None) bool[source]

Watch for QFileOpenEvent.

Parameters:

event (Optional[QEvent])

Return type:

bool

static exitQgis()[source]

deletes provider registry and map layer registry

static externalStorageRegistry() QgsExternalStorageRegistry | None[source]

Returns registry of available external storage implementations.

Added in version 3.20.

Return type:

Optional[QgsExternalStorageRegistry]

static fieldFormatterRegistry() QgsFieldFormatterRegistry | None[source]

Gets the registry of available field formatters.

Return type:

Optional[QgsFieldFormatterRegistry]

static fontManager() QgsFontManager | None[source]

Returns the application font manager, which manages available fonts and font installation for the QGIS instance.

Added in version 3.28.

Return type:

Optional[QgsFontManager]

static getThemeCursor(cursor: QgsApplication.Cursor) QCursor[source]

Helper to get a theme cursor. It will fall back to the default theme if the active theme does not have the required icon. Cursors are automatically scaled to look like a 16px cursor on 96dpi screens.

Parameters:

cursor (QgsApplication.Cursor)

Return type:

QCursor

static getThemeIcon(name: str | None, fillColor: QColor | Qt.GlobalColor = QColor(), strokeColor: QColor | Qt.GlobalColor = QColor()) QIcon[source]

Helper to get a theme icon. It will fall back to the default theme if the active theme does not have the required icon.

Since QGIS 3.20, the optional fillColor and strokeColor arguments can be used to control the color of parameter based SVG icons.

Parameters:
  • name (Optional[str])

  • fillColor (Union[QColor, Qt.GlobalColor] = QColor())

  • strokeColor (Union[QColor, Qt.GlobalColor] = QColor())

Return type:

QIcon

static getThemePixmap(name: str | None, foreColor: QColor | Qt.GlobalColor = QColor(), backColor: QColor | Qt.GlobalColor = QColor(), size: int = 16) QPixmap[source]

Helper to get a theme icon as a pixmap. It will fall back to the default theme if the active theme does not have the required icon.

If foreColor or backColor are specified, then these colors will be used for parametrized colors in SVG files wherever available. If colors are specified then the size argument also must be set.

Parameters:
  • name (Optional[str])

  • foreColor (Union[QColor, Qt.GlobalColor] = QColor())

  • backColor (Union[QColor, Qt.GlobalColor] = QColor())

  • size (int = 16)

Return type:

QPixmap

static gpsBabelFormatRegistry() QgsBabelFormatRegistry | None[source]

Returns the application’s GPSBabel format registry, used for managing GPSBabel formats.

Added in version 3.22.

Return type:

Optional[QgsBabelFormatRegistry]

static gpsConnectionRegistry() QgsGpsConnectionRegistry | None[source]

Returns the application’s GPS connection registry, used for managing GPS connections.

Return type:

Optional[QgsGpsConnectionRegistry]

static i18nPath() str[source]

Returns the path to the translation directory.

Return type:

str

static iconPath(iconFile: str | None) str[source]

Returns path to the desired icon file. First it tries to use the active theme path, then default theme path

Parameters:

iconFile (Optional[str])

Return type:

str

static iconsPath() str[source]

Returns the path to the icons image directory.

Return type:

str

static imageCache() QgsImageCache | None[source]

Returns the application’s image cache, used for caching resampled versions of raster images.

See also

svgCache()

Added in version 3.6.

Return type:

Optional[QgsImageCache]

static initQgis()[source]

loads providers

static instance() QgsApplication | None[source]

Returns the singleton instance of the QgsApplication.

Return type:

Optional[QgsApplication]

static isRunningFromBuildDir() bool[source]

Indicates whether running from build directory (not installed)

Return type:

bool

static labelingEngineRuleRegistry() QgsLabelingEngineRuleRegistry | None[source]

Gets the registry of available labeling engine rules.

Added in version 3.40.

Return type:

Optional[QgsLabelingEngineRuleRegistry]

static layerMetadataProviderRegistry() QgsLayerMetadataProviderRegistry | None[source]

Returns registry of available layer metadata provider implementations.

Added in version 3.28.

Return type:

Optional[QgsLayerMetadataProviderRegistry]

static layoutItemRegistry() QgsLayoutItemRegistry | None[source]

Returns the application’s layout item registry, used for layout item types.

Return type:

Optional[QgsLayoutItemRegistry]

static layoutTemplatePaths() List[str][source]

Returns the paths to layout template directories.

Return type:

List[str]

static libexecPath() str[source]

Returns the path with utility executables (help viewer, crssync, …)

Return type:

str

static libraryPath() str[source]

Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries

Return type:

str

static licenceFilePath() str[source]

Returns the path to the licence file.

Return type:

str

static locale() str[source]

Returns the QGIS locale.

Return type:

str

signal localeChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

static localizedDataPathRegistry() QgsLocalizedDataPathRegistry | None[source]

Returns the registry of data repositories These are used as paths for basemaps, logos, etc. which can be referenced differently across work stations.

Added in version 3.14.

Return type:

Optional[QgsLocalizedDataPathRegistry]

maxConcurrentConnectionsPerPool(self) int[source]

The maximum number of concurrent connections per connections pool.

Note

QGIS may in some situations allocate more than this amount of connections to avoid deadlocks.

Added in version 3.4.

Return type:

int

static maxThreads() int[source]

Gets maximum concurrent thread count

Return type:

int

static messageLog() QgsMessageLog | None[source]

Returns the application’s message log.

Return type:

Optional[QgsMessageLog]

static metadataPath() str[source]

Returns the path to the metadata directory.

Return type:

str

static networkContentFetcherRegistry() QgsNetworkContentFetcherRegistry | None[source]

Returns the application’s network content registry used for fetching temporary files during QGIS session

Added in version 3.2.

Return type:

Optional[QgsNetworkContentFetcherRegistry]

virtual notify(self, receiver: QObject | None, event: QEvent | None) bool[source]

Catch exceptions when sending event to receiver.

Parameters:
  • receiver (Optional[QObject])

  • event (Optional[QEvent])

Return type:

bool

static nullRepresentation() str[source]

Returns the string used to represent the value NULL throughout QGIS.

Note

In general, when passing values around, prefer to use an invalid QVariant. The nullRepresentation() value should only be used in the final presentation step when showing values in a widget or sending it to a web browser.

Return type:

str

signal nullRepresentationChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

static numericFormatRegistry() QgsNumericFormatRegistry | None[source]

Gets the registry of available numeric formats.

Added in version 3.12.

Return type:

Optional[QgsNumericFormatRegistry]

static osName() str[source]

Returns a string name of the operating system QGIS is running on.

See also

platform()

Return type:

str

static pageSizeRegistry() QgsPageSizeRegistry | None[source]

Returns the application’s page size registry, used for managing layout page sizes.

Return type:

Optional[QgsPageSizeRegistry]

static paintEffectRegistry() QgsPaintEffectRegistry | None[source]

Returns the application’s paint effect registry, used for managing paint effects.

Return type:

Optional[QgsPaintEffectRegistry]

static pkgDataPath() str[source]

Returns the common root path of all application data directories.

Return type:

str

static platform() str[source]

Returns the QGIS platform name, e.g., “desktop”, “server”, “qgis_process” or “external” (for external CLI scripts).

See also

osName()

Return type:

str

static plotRegistry() QgsPlotRegistry | None[source]

Returns the application’s plot registry, used for plot types.

Added in version 4.0.

Return type:

Optional[QgsPlotRegistry]

static pluginLayerRegistry() QgsPluginLayerRegistry | None[source]

Returns the application’s plugin layer registry, used for managing plugin layer types.

Return type:

Optional[QgsPluginLayerRegistry]

static pluginPath() str[source]

Returns the path to the application plugin directory.

Return type:

str

static pointCloudRendererRegistry() QgsPointCloudRendererRegistry | None[source]

Returns the application’s point cloud renderer registry, used for managing point cloud layer 2D renderers.

Added in version 3.18.

Return type:

Optional[QgsPointCloudRendererRegistry]

static prefixPath() str[source]

Returns the path to the application prefix directory.

Return type:

str

static processingRegistry() QgsProcessingRegistry | None[source]

Returns the application’s processing registry, used for managing processing providers, algorithms, and various parameters and outputs.

Return type:

Optional[QgsProcessingRegistry]

static profileSourceRegistry() QgsProfileSourceRegistry | None[source]

Returns registry of available profile source implementations.

Added in version 3.38.

Return type:

Optional[QgsProfileSourceRegistry]

static profiler() QgsRuntimeProfiler | None[source]

Returns the application runtime profiler.

Return type:

Optional[QgsRuntimeProfiler]

static projectStorageRegistry() QgsProjectStorageRegistry | None[source]

Returns registry of available project storage implementations.

Added in version 3.2.

Return type:

Optional[QgsProjectStorageRegistry]

static qgisAuthDatabaseFilePath() str[source]

Returns the path to the user authentication database file: qgis-auth.db.

Deprecated since version 3.30: Use qgisAuthDatabaseUri() instead.

Return type:

str

static qgisAuthDatabaseUri() str[source]

Returns the URI to the user authentication database. The URI is be in the format: verbatim<DRIVER>://<USER>:<PASSWORD>@<HOST>:<PORT>/<DATABASE>[?OPTIONS]endverbatim where DATABASE is just the path to the file for SQLite databases. If DRIVER is omitted, PSQLITE is assumed. Optional SCHEMA can be specified as a query parameter.

Added in version 3.40.

Return type:

str

static qgisMasterDatabaseFilePath() str[source]

Returns the path to the master qgis.db file.

Return type:

str

static qgisSettingsDirPath() str[source]

Returns the path to the settings directory in user’s home dir

Return type:

str

static qgisUserDatabaseFilePath() str[source]

Returns the path to the user qgis.db file.

Return type:

str

static qmlImportPath() str[source]

Returns the path where QML components are installed for QGIS Quick library. Returns empty string when QGIS is built without Quick support

Added in version 3.2.

Return type:

str

static recentStyleHandler() QgsRecentStyleHandler | None[source]

Returns the handler for recently used style items.

Added in version 3.22.

Return type:

Optional[QgsRecentStyleHandler]

static registerGdalDriversFromSettings()[source]

Register gdal drivers, excluding the ones mentioned in “gdal/skipList” setting.

Added in version 3.10.

static registerOgrDrivers()[source]

Register OGR drivers ensuring this only happens once. This is a workaround for an issue with older gdal versions that caused duplicate driver name entries to appear in the list of registered drivers when QgsApplication.registerOgrDrivers was called multiple times.

static relativePathToAbsolutePath(rpath: str | None, targetPath: str | None) str[source]

Converts path relative to target to an absolute path

Parameters:
  • rpath (Optional[str])

  • targetPath (Optional[str])

Return type:

str

static renderer3DRegistry() Qgs3DRendererRegistry | None[source]

Returns registry of available 3D renderers.

Return type:

Optional[Qgs3DRendererRegistry]

static rendererRegistry() QgsRendererRegistry | None[source]

Returns the application’s renderer registry, used for managing vector layer renderers.

Return type:

Optional[QgsRendererRegistry]

static reportStyleSheet(styleSheetType: QgsApplication.StyleSheetType = QgsApplication.StyleSheetType.Qt) str[source]

Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet is supported by the widget.

Typically you will use this method by calling:

report_style = QgsApplication.reportStyleSheet()
text_browser_report.document().setDefaultStyleSheet(report_style)

if you are using a QgsWebView you will need to manually inject the CSS into a head -> script tag instead.

Return type:

str

Returns:

the stylesheet CSS rules.

Note

if styleSheetType equals StyleSheetType.Qt you can use the special Qt extensions too, for example the gradient fills for backgrounds.

Parameters:

styleSheetType (QgsApplication.StyleSheetType = QgsApplication.StyleSheetType.Qt)

signal requestForTranslatableObjects[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

static resolvePkgPath() str[source]

Calculate the application pkg path

Return type:

str

Returns:

the resolved pkg path

static restoreGdalDriver(driver: str | None)[source]

Sets the GDAL_SKIP environment variable to exclude the specified driver and then calls GDALDriverManager.AutoSkipDrivers() to unregister it. The driver name should be the short format of the Gdal driver name e.g. GTIFF.

Parameters:

driver (Optional[str])

static scaleBarRendererRegistry() QgsScaleBarRendererRegistry | None[source]

Gets the registry of available scalebar renderers.

Added in version 3.14.

Return type:

Optional[QgsScaleBarRendererRegistry]

static scaleIconSize(standardSize: int, applyDevicePixelRatio: bool = False) int[source]

Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly, whilst still resulting in pixel-perfect sizes for low-dpi displays.

standardSize should be set to a standard icon size, e.g. 16, 24, 48, etc.

Added in version 3.16.

Parameters:
  • standardSize (int)

  • applyDevicePixelRatio (bool = False)

Return type:

int

static sensorRegistry() QgsSensorRegistry | None[source]

Returns the application’s sensor registry, used for sensor types.

Added in version 3.32.

Return type:

Optional[QgsSensorRegistry]

static serverResourcesPath() str[source]

Returns the path to the server resources directory.

Return type:

str

static setAuthDatabaseDirPath(authDbDirPath: str | None)[source]

Alters authentication data base directory path - used by 3rd party apps

Parameters:

authDbDirPath (Optional[str])

static setCustomVariable(name: str | None, value: Any)[source]

Set a single custom expression variable.

Parameters:
  • name (Optional[str])

  • value (Any)

static setCustomVariables(customVariables: Dict[str, Any])[source]

Custom expression variables for this application. Do not include generated variables (like system name, user name etc.)

Parameters:

customVariables (Dict[str, Any])

static setDefaultSvgPaths(pathList: Iterable[str | None])[source]

Alters default svg paths - used by 3rd party apps.

Parameters:

pathList (Iterable[Optional[str]])

static setFileOpenEventReceiver(receiver: QObject | None)[source]

Sets the FileOpen event receiver

Parameters:

receiver (Optional[QObject])

static setLocale(locale: QLocale)[source]

Sets the QGIS locale - used mainly by 3rd party apps and tests. In QGIS this is internally triggered by the application in startup.

Added in version 3.22.2.

Parameters:

locale (QLocale)

static setMaxThreads(maxThreads: int)[source]

Set maximum concurrent thread count

Note

must be between 2 and #cores, -1 means use all available cores

Parameters:

maxThreads (int)

static setNullRepresentation(nullRepresentation: str | None)[source]

Sets the string used to represent the value NULL throughout QGIS.

Note

In general, when passing values around, prefer to use an invalid QVariant. The nullRepresentation() value should only be used in the final presentation step when showing values in a widget or sending it to a web browser.

Parameters:

nullRepresentation (Optional[str])

static setPkgDataPath(pkgDataPath: str | None)[source]

Alters pkg data path - used by 3rd party apps

Parameters:

pkgDataPath (Optional[str])

static setPluginPath(pluginPath: str | None)[source]

Alters plugin path - used by 3rd party apps

Parameters:

pluginPath (Optional[str])

static setPrefixPath(prefixPath: str | None, useDefaultPaths: bool = False)[source]

Alters prefix path - used by 3rd party apps

Parameters:
  • prefixPath (Optional[str])

  • useDefaultPaths (bool = False)

static setSkippedGdalDrivers(skippedGdalDrivers: Iterable[str | None], deferredSkippedGdalDrivers: Iterable[str | None])[source]

Sets the list of gdal drivers that should be disabled (skippedGdalDrivers), but excludes for now the ones defines in deferredSkippedGdalDrivers. This writes the “gdal/skipList” setting.

Added in version 3.10.

Parameters:
  • skippedGdalDrivers (Iterable[Optional[str]])

  • deferredSkippedGdalDrivers (Iterable[Optional[str]])

static setSvgPaths(svgPaths: Iterable[str | None])[source]

Sets the paths to svg directories and invalidates the svg path list cache.

Added in version 3.18.

Parameters:

svgPaths (Iterable[Optional[str]])

static setTemporarilyTrustedProjectsFolders(trustedProjectsFolders: Iterable[str | None])[source]

Sets the list of projects and folders that have been temporarily determined as trusted by the user.

Added in version 4.0.

Parameters:

trustedProjectsFolders (Iterable[Optional[str]])

static setTemporarilyUntrustedProjectsFolders(untrustedProjectsFolders: Iterable[str | None])[source]

Sets the list of projects and folders that have been temporarily determined as untrusted by the user.

Added in version 4.0.

Parameters:

untrustedProjectsFolders (Iterable[Optional[str]])

static setThemeName(themeName: str | None)[source]

Set the active theme to the specified theme. The theme name should be a single word e.g. ‘default’,’classic’. The theme search path usually will be pkgDataPath + “/themes/” + themName + “/” but plugin writers etc can use themeName() as a basis for searching for resources in their own datastores e.g. a Qt4 resource bundle.

Note

A basic test will be carried out to ensure the theme search path based on the supplied theme name exists. If it does not the theme name will be reverted to ‘default’.

Parameters:

themeName (Optional[str])

static setTranslation(translation: str | None)[source]

Set translation locale code

Added in version 3.4.

Parameters:

translation (Optional[str])

static setUITheme(themeName: str | None)[source]

Set the current UI theme used to style the interface. Use uiThemes() to find valid themes to use. Variables found in variables.qss will be added to the stylesheet on load.

Parameters:

themeName (Optional[str]) – The name of the theme.

Note

using an invalid theme name will reset to default

static settingsRegistryCore() QgsSettingsRegistryCore | None[source]

Returns the application’s settings registry, used for managing application settings.

Added in version 3.20.

Deprecated since version 3.30: Use QgsSettings.treeRoot() instead.

Return type:

Optional[QgsSettingsRegistryCore]

static shortNameRegularExpression() QRegularExpression[source]

Returns the short name regular expression for line edit validator

Note

This functionality was previously available as shortNameRegExp for QGIS <= 3.20

Added in version 3.22.

Return type:

QRegularExpression

static showSettings() str[source]

Convenience function to get a summary of the paths used in this application instance useful for debugging mainly.

Return type:

str

static skipGdalDriver(driver: str | None)[source]

Sets the GDAL_SKIP environment variable to include the specified driver and then calls GDALDriverManager.AutoSkipDrivers() to unregister it. The driver name should be the short format of the Gdal driver name e.g. GTIFF.

Parameters:

driver (Optional[str])

static skippedGdalDrivers() List[str][source]

Returns the list of gdal drivers that should be skipped (based on GDAL_SKIP environment variable)

Return type:

List[str]

static sourceCache() QgsSourceCache | None[source]

Returns the application’s source cache, used for caching embedded and remote source strings as local files

Added in version 3.16.

Return type:

Optional[QgsSourceCache]

static splashPath() str[source]

Returns the path to the splash screen image directory.

Return type:

str

static sponsorsFilePath() str[source]

Returns the path to the sponsors file.

Return type:

str

static srsDatabaseFilePath() str[source]

Returns the path to the srs.db file.

Return type:

str

static svgCache() QgsSvgCache | None[source]

Returns the application’s SVG cache, used for caching SVG images and handling parameter replacement within SVG files.

See also

imageCache()

Return type:

Optional[QgsSvgCache]

static svgPaths() List[str][source]

Returns the paths to svg directories.

Return type:

List[str]

static symbol3DRegistry() Qgs3DSymbolRegistry | None[source]

Returns registry of available 3D symbols.

Added in version 3.16.

Return type:

Optional[Qgs3DSymbolRegistry]

static symbolLayerRegistry() QgsSymbolLayerRegistry | None[source]

Returns the application’s symbol layer registry, used for managing symbol layers.

Return type:

Optional[QgsSymbolLayerRegistry]

static systemEnvVars() Dict[str, str]

Returns the system environment variables passed to application.

Return type:

Dict[str, str]

static systemMemorySizeMb() int[source]

Returns the size of the system memory (RAM) in megabytes.

This is only supported on some platforms, and will return -1 if not supported.

Added in version 3.26.

Return type:

int

static taskManager() QgsTaskManager | None[source]

Returns the application’s task manager, used for managing application wide background task handling.

Return type:

Optional[QgsTaskManager]

static temporarilyTrustedProjectsFolders() List[str][source]

Returns the list of projects and folders that have been temporarily determined as trusted by the user.

Added in version 4.0.

Return type:

List[str]

static temporarilyUntrustedProjectsFolders() List[str][source]

Returns the list of projects and folders that have been temporarily determined as untrusted by the user.

Added in version 4.0.

Return type:

List[str]

static themeName() str[source]

Set the active theme to the specified theme. The theme name should be a single word e.g. ‘default’,’classic’. The theme search path usually will be pkgDataPath + “/themes/” + themName + “/” but plugin writers etc can use this method as a basis for searching for resources in their own datastores e.g. a Qt4 resource bundle.

Return type:

str

static tiledSceneRendererRegistry() QgsTiledSceneRendererRegistry | None[source]

Returns the application’s tiled scene renderer registry, used for managing tiled scene layer 2D renderers.

Added in version 3.34.

Return type:

Optional[QgsTiledSceneRendererRegistry]

translation(self) str[source]

Returns the current application translation locale code

See also

setTranslation()

Added in version 3.22.

Return type:

str

static translatorsFilePath() str[source]

Returns the path to the sponsors file.

Return type:

str

static uiThemes() Dict[str, str]

All themes found in ~/.qgis3/themes folder. The path is to the root folder for the theme

Return type:

Dict[str, str]

Returns:

A hash of theme name and theme path. Valid theme folders contain style.qss

Note

Valid theme folders must contain a style.qss file.

static userFullName() str[source]

Returns the user’s operating system login account full display name.

See also

userLoginName()

Return type:

str

static userLoginName() str[source]

Returns the user’s operating system login account name.

See also

userFullName()

Return type:

str

static userStylePath() str[source]

Returns the path to user’s style.

Return type:

str

static userThemesFolder() str[source]

Returns the path to user’s themes folder

Return type:

str

static validityCheckRegistry() QgsValidityCheckRegistry | None[source]

Returns the application’s validity check registry, used for managing validity checks.

Added in version 3.6.

Return type:

Optional[QgsValidityCheckRegistry]