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¶
Base classes¶
Methods
Emits the signal to collect all the strings of .qgs to be included in ts file |
|
The maximum number of concurrent connections per connections pool. |
|
Returns the current application translation locale code |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsApplication. See the FAQ for more details.
Watch for QFileOpenEvent. |
|
Catch exceptions when sending event to receiver. |
Static Methods
Converts absolute path to path relative to target |
|
Returns the action scope registry. |
|
Returns the path to the currently active theme directory. |
|
Returns the application's annotation item registry, used for annotation item types. |
|
Gets application icon |
|
Returns the QGIS application full name. |
|
Apply the skipped drivers list to gdal |
|
Returns the application's authentication configuration storage registry |
|
Returns the application's authentication manager instance |
|
Returns the path to the authors file. |
|
Returns the application's bookmark manager, used for storing installation-wide bookmarks. |
|
Returns path to the build output directory. |
|
Returns path to the source directory. |
|
Returns the application's callout registry, used for managing callout types. |
|
Returns the application's classification methods registry, used in graduated renderer |
|
Returns the application's color scheme registry, used for managing color schemes. |
|
Returns the application's connection registry, used for managing saved data provider connections. |
|
Returns the path to the contributors file. |
|
Returns the application's coordinate reference system (CRS) registry, which handles known CRS definitions (including user-defined CRSes). |
|
initialize qgis.db |
|
Create the users theme folder |
|
Custom expression variables for this application. |
|
Returns the application's data item provider registry, which keeps a list of data item providers that may add items to the browser tree. |
|
Returns the database query log. |
|
Returns a shared |
|
Returns the path to default style (works as a starting point). |
|
Returns the path to the default theme directory. |
|
Returns the path to default themes folder from install (works as a starting point). |
|
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. |
|
Returns the path to the developers map file. |
|
Returns the path to the donors file. |
|
Returns whether this machine uses big or little endian |
|
deletes provider registry and map layer registry |
|
Returns registry of available external storage implementations. |
|
Gets the registry of available field formatters. |
|
Returns the application font manager, which manages available fonts and font installation for the QGIS instance. |
|
Helper to get a theme cursor. |
|
Helper to get a theme icon. |
|
Helper to get a theme icon as a pixmap. |
|
Returns the application's GPSBabel format registry, used for managing GPSBabel formats. |
|
Returns the application's GPS connection registry, used for managing GPS connections. |
|
Returns the path to the translation directory. |
|
Returns path to the desired icon file. |
|
Returns the path to the icons image directory. |
|
Returns the application's image cache, used for caching resampled versions of raster images. |
|
loads providers |
|
Returns the singleton instance of the QgsApplication. |
|
Indicates whether running from build directory (not installed) |
|
Gets the registry of available labeling engine rules. |
|
Returns registry of available layer metadata provider implementations. |
|
Returns the application's layout item registry, used for layout item types. |
|
Returns the paths to layout template directories. |
|
Returns the path with utility executables (help viewer, crssync, ...) |
|
Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries |
|
Returns the path to the licence file. |
|
Returns the QGIS locale. |
|
Returns the registry of data repositories These are used as paths for basemaps, logos, etc. |
|
Gets maximum concurrent thread count |
|
Returns the application's message log. |
|
Returns the path to the metadata directory. |
|
Returns the application's network content registry used for fetching temporary files during QGIS session |
|
Returns the string used to represent the value NULL throughout QGIS. |
|
Gets the registry of available numeric formats. |
|
Returns a string name of the operating system QGIS is running on. |
|
Returns the application's page size registry, used for managing layout page sizes. |
|
Returns the application's paint effect registry, used for managing paint effects. |
|
Returns the common root path of all application data directories. |
|
Returns the QGIS platform name, e.g., "desktop", "server", "qgis_process" or "external" (for external CLI scripts). |
|
Returns the application's plugin layer registry, used for managing plugin layer types. |
|
Returns the path to the application plugin directory. |
|
Returns the application's point cloud renderer registry, used for managing point cloud layer 2D renderers. |
|
Returns the path to the application prefix directory. |
|
Returns the application's processing registry, used for managing processing providers, algorithms, and various parameters and outputs. |
|
Returns registry of available profile source implementations. |
|
Returns the application runtime profiler. |
|
Returns registry of available project storage implementations. |
|
Returns the path to the user authentication database file: qgis-auth.db. |
|
Returns the URI to the user authentication database. |
|
Returns the path to the master qgis.db file. |
|
Returns the path to the settings directory in user's home dir |
|
Returns the path to the user qgis.db file. |
|
Returns the path where QML components are installed for QGIS Quick library. |
|
Returns the handler for recently used style items. |
|
Register gdal drivers, excluding the ones mentioned in "gdal/skipList" setting. |
|
Register OGR drivers ensuring this only happens once. |
|
Converts path relative to target to an absolute path |
|
Returns registry of available 3D renderers. |
|
Returns the application's renderer registry, used for managing vector layer renderers. |
|
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet is supported by the widget. |
|
Calculate the application pkg path |
|
Sets the GDAL_SKIP environment variable to exclude the specified driver and then calls GDALDriverManager.AutoSkipDrivers() to unregister it. |
|
Gets the registry of available scalebar renderers. |
|
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. |
|
Returns the application's sensor registry, used for sensor types. |
|
Returns the path to the server resources directory. |
|
Alters authentication data base directory path - used by 3rd party apps |
|
Set a single custom expression variable. |
|
Custom expression variables for this application. |
|
Alters default svg paths - used by 3rd party apps. |
|
Sets the FileOpen event receiver |
|
Sets the QGIS locale - used mainly by 3rd party apps and tests. |
|
Set maximum concurrent thread count |
|
Sets the string used to represent the value NULL throughout QGIS. |
|
Alters pkg data path - used by 3rd party apps |
|
Alters plugin path - used by 3rd party apps |
|
Alters prefix path - used by 3rd party apps |
|
Sets the list of gdal drivers that should be disabled (skippedGdalDrivers), but excludes for now the ones defines in deferredSkippedGdalDrivers. |
|
Sets the paths to svg directories and invalidates the svg path list cache. |
|
Set the active theme to the specified theme. |
|
Set translation locale code |
|
Set the current UI theme used to style the interface. |
|
Returns the application's settings registry, used for managing application settings. |
|
Returns the short name regular expression for line edit validator |
|
Convenience function to get a summary of the paths used in this application instance useful for debugging mainly. |
|
Sets the GDAL_SKIP environment variable to include the specified driver and then calls GDALDriverManager.AutoSkipDrivers() to unregister it. |
|
Returns the list of gdal drivers that should be skipped (based on GDAL_SKIP environment variable) |
|
Returns the application's source cache, used for caching embedded and remote source strings as local files |
|
Returns the path to the splash screen image directory. |
|
Returns the path to the sponsors file. |
|
Returns the path to the srs.db file. |
|
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement within SVG files. |
|
Returns the paths to svg directories. |
|
Returns registry of available 3D symbols. |
|
Returns the application's symbol layer registry, used for managing symbol layers. |
|
Returns the system environment variables passed to application. |
|
Returns the size of the system memory (RAM) in megabytes. |
|
Returns the application's task manager, used for managing application wide background task handling. |
|
Set the active theme to the specified theme. |
|
Returns the application's tiled scene renderer registry, used for managing tiled scene layer 2D renderers. |
|
Returns the path to the sponsors file. |
|
All themes found in ~/.qgis3/themes folder. |
|
Returns the user's operating system login account full display name. |
|
Returns the user's operating system login account name. |
|
Returns the path to user's style. |
|
Returns the path to user's themes folder |
|
Returns the application's validity check registry, used for managing validity checks. |
Signals
Emitted whenever a custom global variable changes. |
|
Emitted when project locale has been changed. |
|
Emitted when the string representing the NULL value is changed. |
|
Emitted when project strings which require translation are being collected for inclusion in a .ts file. |
Attributes
- 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, orFalse
for a console only applicationprofileFolder (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 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
Added in version 3.30.
- Return type:
str
- static applyGdalSkippedDrivers()[source]¶
Apply the skipped drivers list to gdal
See also
See also
See also
- 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 initQgisSee also
- Return type:
Optional[QgsAuthManager]
- 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 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]
- 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 (seeQgsStyle.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 developersMapFilePath() str [source]¶
Returns the path to the developers map file. The developers map was created by using leaflet framework, it shows the contributors.json file.
- Return type:
str
- static endian() QgsApplication.endian_t [source]¶
Returns whether this machine uses big or little endian
- Return type:
- class endian_t¶
Bases:
int
- virtual event(self, event: QEvent | None) bool [source]¶
Watch for QFileOpenEvent.
- Parameters:
event (Optional[QEvent])
- Return type:
bool
- 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
andstrokeColor
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
orbackColor
are specified, then these colors will be used for parametrized colors in SVG files wherever available. If colors are specified then thesize
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 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 imageCache() QgsImageCache | None [source]¶
Returns the application’s image cache, used for caching resampled versions of raster images.
See also
Added in version 3.6.
- Return type:
Optional[QgsImageCache]
- 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
- signal localeChanged[source]¶
Emitted when project locale has been changed.
Added in version 3.22.2.
- 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.
See also
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 messageLog() QgsMessageLog | None [source]¶
Returns the application’s message log.
- Return type:
Optional[QgsMessageLog]
- 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.See also
See also
- Return type:
str
- signal nullRepresentationChanged[source]¶
Emitted when the string representing the NULL value is changed.
See also
See also
- 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
- 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
- Return type:
str
- 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(translationContext: QgsTranslationContext)[source]¶
Emitted when project strings which require translation are being collected for inclusion in a .ts file. In order to register translatable strings, connect to this signal and register the strings within the specified
translationContext
.Added in version 3.4.
- Parameters:
translationContext (QgsTranslationContext)
- 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.See also
See also
- 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 indeferredSkippedGdalDrivers
. 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 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 svgCache() QgsSvgCache | None [source]¶
Returns the application’s SVG cache, used for caching SVG images and handling parameter replacement within SVG files.
See also
- Return type:
Optional[QgsSvgCache]
- 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 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
Added in version 3.22.
- 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
- Return type:
str
- static userLoginName() str [source]¶
Returns the user’s operating system login account name.
See also
- 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]