Class: QgsApplication¶
- class qgis.core.QgsApplication¶
Bases:
PyQt5.QtWidgets.QApplication
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.
QgsApplication(argv: List, GUIenabled: bool, profileFolder: str = ‘’, platformName: str = ‘’) Constructor for QgsApplication.
- Parameters:
argv – command line arguments
GUIenabled – set to
True
if a GUI application is required, orFalse
for a console only applicationprofileFolder – optional string representing the profile to load at startup
platformName –
the QGIS platform name, e.g., “desktop”, “server”, “qgis_process” or “external” (for external CLI scripts)
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
Apply the skipped drivers list to gdal
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
Emits the signal to collect all the strings of .qgs to be included in ts file
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
QgsStyleModel
containing the default style library (seeQgsStyle.defaultStyle()
).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
Watch for QFileOpenEvent.
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)
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.
The maximum number of concurrent connections per connections pool.
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
Catch exceptions when sending event to receiver.
This string is 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 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 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 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
copydoc
nullRepresentation()
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 indeferredSkippedGdalDrivers
.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 current application translation locale code
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
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
Attributes
- 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¶
- absolutePathToRelativePath(apath: str, targetPath: str) str ¶
Converts absolute path to path relative to target
- Parameters:
apath (str) –
targetPath (str) –
- Return type:
str
- actionScopeRegistry() QgsActionScopeRegistry ¶
Returns the action scope registry.
New in version 3.0.
- Return type:
- activeThemePath() str ¶
Returns the path to the currently active theme directory.
- Return type:
str
- annotationItemRegistry() QgsAnnotationItemRegistry ¶
Returns the application’s annotation item registry, used for annotation item types.
New in version 3.16.
- Return type:
- appIconPath() str ¶
Gets application icon
- Return type:
str
- applyGdalSkippedDrivers()¶
Apply the skipped drivers list to gdal
See also
See also
See also
- authManager() QgsAuthManager ¶
Returns the application’s authentication manager instance
Note
this can be
None
if called before initQgisSee also
New in version 3.0.
- Return type:
- authorsFilePath() str ¶
Returns the path to the authors file.
- Return type:
str
- bookmarkManager() QgsBookmarkManager ¶
Returns the application’s bookmark manager, used for storing installation-wide bookmarks.
New in version 3.10.
- Return type:
- buildOutputPath() str ¶
Returns path to the build output directory. Valid only when running from build directory
- Return type:
str
- buildSourcePath() str ¶
Returns path to the source directory. Valid only when running from build directory
- Return type:
str
- calloutRegistry() QgsCalloutRegistry ¶
Returns the application’s callout registry, used for managing callout types.
New in version 3.10.
- Return type:
- childEvent(self, QChildEvent)¶
- classificationMethodRegistry() QgsClassificationMethodRegistry ¶
Returns the application’s classification methods registry, used in graduated renderer
New in version 3.10.
- Return type:
- collectTranslatableObjects(self, translationContext: QgsTranslationContext)¶
Emits the signal to collect all the strings of .qgs to be included in ts file
New in version 3.4.
- Parameters:
translationContext (QgsTranslationContext) –
- colorSchemeRegistry() QgsColorSchemeRegistry ¶
Returns the application’s color scheme registry, used for managing color schemes.
New in version 3.0.
- Return type:
- connectNotify(self, QMetaMethod)¶
- connectionRegistry() QgsConnectionRegistry ¶
Returns the application’s connection registry, used for managing saved data provider connections.
New in version 3.14.
- Return type:
- contributorsFilePath() str ¶
Returns the path to the contributors file. Contributors are people who have submitted patches but don’t have commit access.
- Return type:
str
- coordinateReferenceSystemRegistry() QgsCoordinateReferenceSystemRegistry ¶
Returns the application’s coordinate reference system (CRS) registry, which handles known CRS definitions (including user-defined CRSes).
New in version 3.18.
- Return type:
- createDatabase(errorMessage: str = '') bool ¶
initialize qgis.db
- Parameters:
errorMessage (str = '') –
- Return type:
bool
- createThemeFolder() bool ¶
Create the users theme folder
- Return type:
bool
- customEvent(self, QEvent)¶
- customVariables() Dict[str, Any] ¶
Custom expression variables for this application. This does not include generated variables (like system name, user name etc.)
New in version 3.0.
- Return type:
Dict[str, Any]
- customVariablesChanged¶
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.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- dataItemProviderRegistry() QgsDataItemProviderRegistry ¶
Returns the application’s data item provider registry, which keeps a list of data item providers that may add items to the browser tree.
New in version 3.0.
- Return type:
- databaseQueryLog() QgsDatabaseQueryLog ¶
Returns the database query log.
New in version 3.24.
- Return type:
- defaultStyleModel() QgsStyleModel ¶
Returns a shared
QgsStyleModel
containing the default style library (seeQgsStyle.defaultStyle()
).Using this shared model instead of creating a new
QgsStyleModel
improves performance.New in version 3.10.
- Return type:
- defaultStylePath() str ¶
Returns the path to default style (works as a starting point).
- Return type:
str
- defaultThemePath() str ¶
Returns the path to the default theme directory.
- Return type:
str
- defaultThemesFolder() str ¶
Returns the path to default themes folder from install (works as a starting point).
- Return type:
str
- deferredSkippedGdalDrivers() List[str] ¶
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.
New in version 3.10.
- Return type:
List[str]
- developersMapFilePath() str ¶
Returns the path to the developers map file. The developers map was created by using leaflet framework, it shows the contributors.json file.
New in version 2.7.
- Return type:
str
- disconnectNotify(self, QMetaMethod)¶
- donorsFilePath() str ¶
Returns the path to the donors file.
- Return type:
str
- endian() QgsApplication.endian_t ¶
Returns whether this machine uses big or little endian
- Return type:
- class endian_t¶
Bases:
int
- event(self, event: QEvent) bool ¶
Watch for QFileOpenEvent.
- Parameters:
event (QEvent) –
- Return type:
bool
- exitQgis()¶
deletes provider registry and map layer registry
- externalStorageRegistry() QgsExternalStorageRegistry ¶
Returns registry of available external storage implementations.
New in version 3.20.
- Return type:
- fieldFormatterRegistry() QgsFieldFormatterRegistry ¶
Gets the registry of available field formatters.
- Return type:
- fontManager() QgsFontManager ¶
Returns the application font manager, which manages available fonts and font installation for the QGIS instance.
New in version 3.28.
- Return type:
- getThemeCursor(cursor: QgsApplication.Cursor) QCursor ¶
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
- getThemeIcon(name: str, fillColor: QColor | Qt.GlobalColor | QGradient = QColor(), strokeColor: QColor | Qt.GlobalColor | QGradient = QColor()) QIcon ¶
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 (str) –
fillColor (Union[QColor) –
strokeColor (Union[QColor) –
- Return type:
QIcon
- getThemePixmap(name: str, foreColor: QColor | Qt.GlobalColor | QGradient = QColor(), backColor: QColor | Qt.GlobalColor | QGradient = QColor(), size: int = 16) QPixmap ¶
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 (str) –
foreColor (Union[QColor) –
backColor (Union[QColor) –
size (int = 16) –
- Return type:
QPixmap
- gpsBabelFormatRegistry() QgsBabelFormatRegistry ¶
Returns the application’s GPSBabel format registry, used for managing GPSBabel formats.
New in version 3.22.
- Return type:
- gpsConnectionRegistry() QgsGpsConnectionRegistry ¶
Returns the application’s GPS connection registry, used for managing GPS connections.
New in version 3.0.
- Return type:
- i18nPath() str ¶
Returns the path to the translation directory.
- Return type:
str
- iconPath(iconFile: str) str ¶
Returns path to the desired icon file. First it tries to use the active theme path, then default theme path
- Parameters:
iconFile (str) –
- Return type:
str
- iconsPath() str ¶
Returns the path to the icons image directory.
- Return type:
str
- imageCache() QgsImageCache ¶
Returns the application’s image cache, used for caching resampled versions of raster images.
See also
New in version 3.6.
- Return type:
- initQgis()¶
loads providers
- instance() QgsApplication ¶
Returns the singleton instance of the QgsApplication.
New in version 3.0.
- Return type:
- isRunningFromBuildDir() bool ¶
Indicates whether running from build directory (not installed)
- Return type:
bool
- isSignalConnected(self, QMetaMethod) bool ¶
- layerMetadataProviderRegistry() QgsLayerMetadataProviderRegistry ¶
Returns registry of available layer metadata provider implementations.
New in version 3.28.
- Return type:
- layoutItemRegistry() QgsLayoutItemRegistry ¶
Returns the application’s layout item registry, used for layout item types.
New in version 3.0.
- Return type:
- layoutTemplatePaths() List[str] ¶
Returns the paths to layout template directories.
New in version 3.0.
- Return type:
List[str]
- libexecPath() str ¶
Returns the path with utility executables (help viewer, crssync, …)
- Return type:
str
- libraryPath() str ¶
Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries
- Return type:
str
- licenceFilePath() str ¶
Returns the path to the licence file.
- Return type:
str
- locale() str ¶
Returns the QGIS locale.
New in version 3.0.
- Return type:
str
- localeChanged¶
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.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- localizedDataPathRegistry() QgsLocalizedDataPathRegistry ¶
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
New in version 3.14.
- Return type:
- maxConcurrentConnectionsPerPool(self) int ¶
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.
New in version 3.4.
- Return type:
int
- maxThreads() int ¶
Gets maximum concurrent thread count
New in version 2.4.
- Return type:
int
- messageLog() QgsMessageLog ¶
Returns the application’s message log.
New in version 3.0.
- Return type:
- metadataPath() str ¶
Returns the path to the metadata directory.
New in version 3.0.
- Return type:
str
- networkContentFetcherRegistry() QgsNetworkContentFetcherRegistry ¶
Returns the application’s network content registry used for fetching temporary files during QGIS session
New in version 3.2.
- Return type:
- notify(self, receiver: QObject, event: QEvent) bool ¶
Catch exceptions when sending event to receiver.
- Parameters:
receiver (QObject) –
event (QEvent) –
- Return type:
bool
- nullRepresentation() str ¶
This string is used to represent the value NULL throughout QGIS.
In general, when passing values around, prefer to use a null QVariant QVariant( field.type() ) or QVariant( QVariant.Int ). This 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
- nullRepresentationChanged¶
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.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- numericFormatRegistry() QgsNumericFormatRegistry ¶
Gets the registry of available numeric formats.
New in version 3.12.
- Return type:
- osName() str ¶
Returns a string name of the operating system QGIS is running on.
See also
New in version 2.14.
- Return type:
str
- pageSizeRegistry() QgsPageSizeRegistry ¶
Returns the application’s page size registry, used for managing layout page sizes.
New in version 3.0.
- Return type:
- paintEffectRegistry() QgsPaintEffectRegistry ¶
Returns the application’s paint effect registry, used for managing paint effects.
New in version 3.0.
- Return type:
- pkgDataPath() str ¶
Returns the common root path of all application data directories.
- Return type:
str
- platform() str ¶
Returns the QGIS platform name, e.g., “desktop”, “server”, “qgis_process” or “external” (for external CLI scripts).
See also
New in version 2.14.
- Return type:
str
- pluginLayerRegistry() QgsPluginLayerRegistry ¶
Returns the application’s plugin layer registry, used for managing plugin layer types.
New in version 3.0.
- Return type:
- pluginPath() str ¶
Returns the path to the application plugin directory.
- Return type:
str
- pointCloudRendererRegistry() QgsPointCloudRendererRegistry ¶
Returns the application’s point cloud renderer registry, used for managing point cloud layer 2D renderers.
New in version 3.18.
- Return type:
- prefixPath() str ¶
Returns the path to the application prefix directory.
- Return type:
str
- processingRegistry() QgsProcessingRegistry ¶
Returns the application’s processing registry, used for managing processing providers, algorithms, and various parameters and outputs.
New in version 3.0.
- Return type:
- profiler() QgsRuntimeProfiler ¶
Returns the application runtime profiler.
New in version 3.0.
- Return type:
- projectStorageRegistry() QgsProjectStorageRegistry ¶
Returns registry of available project storage implementations.
New in version 3.2.
- Return type:
- qgisAuthDatabaseFilePath() str ¶
Returns the path to the user authentication database file: qgis-auth.db.
- Return type:
str
- qgisMasterDatabaseFilePath() str ¶
Returns the path to the master qgis.db file.
- Return type:
str
- qgisSettingsDirPath() str ¶
Returns the path to the settings directory in user’s home dir
- Return type:
str
- qgisUserDatabaseFilePath() str ¶
Returns the path to the user qgis.db file.
- Return type:
str
- qmlImportPath() str ¶
Returns the path where QML components are installed for QGIS Quick library. Returns empty string when QGIS is built without Quick support
New in version 3.2.
- Return type:
str
- receivers(self, PYQT_SIGNAL) int ¶
- recentStyleHandler() QgsRecentStyleHandler ¶
Returns the handler for recently used style items.
New in version 3.22.
- Return type:
- registerGdalDriversFromSettings()¶
Register gdal drivers, excluding the ones mentioned in “gdal/skipList” setting.
New in version 3.10.
- registerOgrDrivers()¶
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.
- relativePathToAbsolutePath(rpath: str, targetPath: str) str ¶
Converts path relative to target to an absolute path
- Parameters:
rpath (str) –
targetPath (str) –
- Return type:
str
- renderer3DRegistry() Qgs3DRendererRegistry ¶
Returns registry of available 3D renderers.
New in version 3.0.
- Return type:
- rendererRegistry() QgsRendererRegistry ¶
Returns the application’s renderer registry, used for managing vector layer renderers.
New in version 3.0.
- Return type:
- reportStyleSheet(styleSheetType: QgsApplication.StyleSheetType = QgsApplication.StyleSheetType.Qt) str ¶
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 doing: QString myStyle =
QgsApplication.reportStyleSheet()
; textBrowserReport->:py:func:~QgsApplication.document->setDefaultStyleSheet(myStyle); if you are using aQgsWebView
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) –
- requestForTranslatableObjects¶
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.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- resolvePkgPath() str ¶
Calculate the application pkg path
- Return type:
str
- Returns:
the resolved pkg path
- restoreGdalDriver(driver: str)¶
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 (str) –
- scaleBarRendererRegistry() QgsScaleBarRendererRegistry ¶
Gets the registry of available scalebar renderers.
New in version 3.14.
- Return type:
- scaleIconSize(standardSize: int, applyDevicePixelRatio: bool = False) int ¶
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.New in version 3.16.
- Parameters:
standardSize (int) –
applyDevicePixelRatio (bool = False) –
- Return type:
int
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- serverResourcesPath() str ¶
Returns the path to the server resources directory.
- Return type:
str
- setAuthDatabaseDirPath(authDbDirPath: str)¶
Alters authentication data base directory path - used by 3rd party apps
- Parameters:
authDbDirPath (str) –
- setCustomVariable(name: str, value: Any)¶
Set a single custom expression variable.
New in version 3.0.
- Parameters:
name (str) –
value (Any) –
- setCustomVariables(customVariables: Dict[str, Any])¶
Custom expression variables for this application. Do not include generated variables (like system name, user name etc.)
New in version 3.0.
- Parameters:
customVariables (Dict[str) –
- setDefaultSvgPaths(pathList: Iterable[str])¶
Alters default svg paths - used by 3rd party apps.
- Parameters:
pathList (Iterable[str]) –
- setFileOpenEventReceiver(receiver: QObject)¶
Sets the FileOpen event receiver
- Parameters:
receiver (QObject) –
- setLocale(locale: QLocale)¶
Sets the QGIS locale - used mainly by 3rd party apps and tests. In QGIS this is internally triggered by the application in startup.
New in version 3.22.2.
- Parameters:
locale (QLocale) –
- setMaxThreads(maxThreads: int)¶
Set maximum concurrent thread count
Note
must be between 2 and #cores, -1 means use all available cores
New in version 2.4.
- Parameters:
maxThreads (int) –
- setNullRepresentation(nullRepresentation: str)¶
copydoc
nullRepresentation()
- Parameters:
nullRepresentation (str) –
- setPkgDataPath(pkgDataPath: str)¶
Alters pkg data path - used by 3rd party apps
- Parameters:
pkgDataPath (str) –
- setPluginPath(pluginPath: str)¶
Alters plugin path - used by 3rd party apps
- Parameters:
pluginPath (str) –
- setPrefixPath(prefixPath: str, useDefaultPaths: bool = False)¶
Alters prefix path - used by 3rd party apps
- Parameters:
prefixPath (str) –
useDefaultPaths (bool = False) –
- setSkippedGdalDrivers(skippedGdalDrivers: Iterable[str], deferredSkippedGdalDrivers: Iterable[str])¶
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.New in version 3.10.
- Parameters:
skippedGdalDrivers (Iterable[str]) –
deferredSkippedGdalDrivers (Iterable[str]) –
- setSvgPaths(svgPaths: Iterable[str])¶
Sets the paths to svg directories and invalidates the svg path list cache.
New in version 3.18.
- Parameters:
svgPaths (Iterable[str]) –
- setThemeName(themeName: str)¶
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 (str) –
- setTranslation(translation: str)¶
Set translation locale code
New in version 3.4.
- Parameters:
translation (str) –
- setUITheme(themeName: str)¶
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 (str) – The name of the theme.
Note
using an invalid theme name will reset to default
- settingsRegistryCore() QgsSettingsRegistryCore ¶
Returns the application’s settings registry, used for managing application settings.
New in version 3.20.
- Return type:
- shortNameRegularExpression() QRegularExpression ¶
Returns the short name regular expression for line edit validator
Note
This functionality was previously available as shortNameRegExp for QGIS <= 3.20
New in version 3.22.
- Return type:
QRegularExpression
- showSettings() str ¶
Convenience function to get a summary of the paths used in this application instance useful for debugging mainly.
- Return type:
str
- skipGdalDriver(driver: str)¶
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 (str) –
- skippedGdalDrivers() List[str] ¶
Returns the list of gdal drivers that should be skipped (based on GDAL_SKIP environment variable)
- Return type:
List[str]
- sourceCache() QgsSourceCache ¶
Returns the application’s source cache, used for caching embedded and remote source strings as local files
New in version 3.16.
- Return type:
- splashPath() str ¶
Returns the path to the splash screen image directory.
- Return type:
str
- sponsorsFilePath() str ¶
Returns the path to the sponsors file.
- Return type:
str
- srsDatabaseFilePath() str ¶
Returns the path to the srs.db file.
- Return type:
str
- svgCache() QgsSvgCache ¶
Returns the application’s SVG cache, used for caching SVG images and handling parameter replacement within SVG files.
See also
New in version 3.0.
- Return type:
- svgPaths() List[str] ¶
Returns the paths to svg directories.
- Return type:
List[str]
- symbol3DRegistry() Qgs3DSymbolRegistry ¶
Returns registry of available 3D symbols.
New in version 3.16.
- Return type:
- symbolLayerRegistry() QgsSymbolLayerRegistry ¶
Returns the application’s symbol layer registry, used for managing symbol layers.
New in version 3.0.
- Return type:
- systemEnvVars() Dict[str, str] ¶
Returns the system environment variables passed to application.
- Return type:
Dict[str, str]
- systemMemorySizeMb() int ¶
Returns the size of the system memory (RAM) in megabytes.
This is only supported on some platforms, and will return -1 if not supported.
New in version 3.26.
- Return type:
int
- taskManager() QgsTaskManager ¶
Returns the application’s task manager, used for managing application wide background task handling.
New in version 3.0.
- Return type:
- themeName() str ¶
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
- timerEvent(self, QTimerEvent)¶
- translation(self) str ¶
Returns the current application translation locale code
See also
New in version 3.22.
- Return type:
str
- translatorsFilePath() str ¶
Returns the path to the sponsors file.
- Return type:
str
- 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.
- userFullName() str ¶
Returns the user’s operating system login account full display name.
See also
New in version 2.14.
- Return type:
str
- userLoginName() str ¶
Returns the user’s operating system login account name.
See also
New in version 2.14.
- Return type:
str
- userStylePath() str ¶
Returns the path to user’s style.
- Return type:
str
- userThemesFolder() str ¶
Returns the path to user’s themes folder
- Return type:
str
- validityCheckRegistry() QgsValidityCheckRegistry ¶
Returns the application’s validity check registry, used for managing validity checks.
New in version 3.6.
- Return type: