Subgroup: other
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.
Methods
aboutQt
absolutePathToRelativePath
Converts absolute path to path relative to target actionScopeRegistry
Returns the action scope registry. activeModalWidget
activePopupWidget
activeThemePath
Returns the path to the currently active theme directory. activeWindow
addLibraryPath
alert
allWidgets
allWindows
appIconPath
get application icon applicationDirPath
applicationDisplayName
applicationDisplayNameChanged
applicationFilePath
applicationName
applicationPid
applicationState
applicationVersion
applyGdalSkippedDrivers
Apply the skipped drivers list to gdal arguments
authManager
Returns the application’s authentication manager instance authorsFilePath
Returns the path to the authors file. autoSipEnabled
beep
blockSignals
buildOutputPath
Returns path to the build output directory. buildSourcePath
Returns path to the source directory. changeOverrideCursor
childEvent
children
clipboard
closeAllWindows
closingDown
colorSchemeRegistry
Returns the application’s color scheme registry, used for managing color schemes. colorSpec
composerTemplatePaths
Returns the paths to composer template directories connectNotify
contributorsFilePath
Returns the path to the contributors file. createDatabase
initialize qgis.db createThemeFolder
Create the users theme folder cursorFlashTime
customEvent
customVariables
Custom expression variables for this application. dataItemProviderRegistry
Returns the application’s data item provider registry, which keeps a list of data item providers that may add items to the browser tree. defaultStylePath
Returns the path to default style (works as a starting point). defaultThemePath
Returns the path to the default theme directory. defaultThemesFolder
Returns the path to default themes folder from install (works as a starting point). deleteLater
desktop
desktopFileName
desktopSettingsAware
developersMapFilePath
Returns the path to the developers map file. devicePixelRatio
disconnect
disconnectNotify
donorsFilePath
Returns the path to the donors file. doubleClickInterval
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
endian
Returns whether this machine uses big or little endian event
Watch for QFileOpenEvent. eventDispatcher
eventFilter
exec
exec_
exit
exitQgis
deletes provider registry and map layer registry fieldFormatterRegistry
Get the registry of available field formatters. findChild
findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject findChildren
findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] flush
focusObject
focusWidget
focusWindow
font
font(QWidget) -> QFont fontMetrics
getThemeCursor
Helper to get a theme cursor. getThemeIcon
Helper to get a theme icon. getThemePixmap
Helper to get a theme icon as a pixmap. globalStrut
gpsConnectionRegistry
Returns the application’s GPS connection registry, used for managing GPS connections. hasPendingEvents
i18nPath
Returns the path to the translation directory. iconPath
Returns path to the desired icon file. iconsPath
Returns the path to the icons image directory. inherits
initQgis
loads providers installEventFilter
installNativeEventFilter
installTranslator
instance
Returns the singleton instance of the QgsApplication. isEffectEnabled
isFallbackSessionManagementEnabled
isLeftToRight
isQuitLockEnabled
isRightToLeft
isRunningFromBuildDir
Indicates whether running from build directory (not installed) isSavingSession
isSessionRestored
isSetuidAllowed
isSignalConnected
isWidgetType
isWindowType
keyboardInputInterval
keyboardModifiers
killTimer
layoutDirection
layoutItemRegistry
Returns the application’s layout item registry, used for layout item types. libexecPath
Returns the path with utility executables (help viewer, crssync, …) libraryPath
Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries libraryPaths
licenceFilePath
Returns the path to the licence file. locale
Returns the QGIS locale. maxThreads
Get maximum concurrent thread count messageLog
Returns the application’s message log. metaObject
metadataPath
Returns the path to the metadata directory. modalWindow
mouseButtons
moveToThread
notify
Catch exceptions when sending event to receiver. nullRepresentation
This string is used to represent the value NULL throughout QGIS. objectName
organizationDomain
organizationName
osName
Returns a string name of the operating system QGIS is running on. overrideCursor
pageSizeRegistry
Returns the application’s page size registry, used for managing layout page sizes. paintEffectRegistry
Returns the application’s paint effect registry, used for managing paint effects. palette
palette(QWidget) -> QPalette parent
pkgDataPath
Returns the common root path of all application data directories. platform
Returns the QGIS platform name, e.g., “desktop” or “server”. platformName
pluginLayerRegistry
Returns the application’s plugin layer registry, used for managing plugin layer types. pluginPath
Returns the path to the application plugin directory. postEvent
prefixPath
Returns the path to the application prefix directory. primaryScreen
processEvents
processEvents(Union[QEventLoop.ProcessEventsFlags, QEventLoop.ProcessEventsFlag], int) processingRegistry
Returns the application’s processing registry, used for managing processing providers, algorithms, and various parameters and outputs. profiler
Returns the application runtime profiler. property
pyqtConfigure
Each keyword argument is either the name of a Qt property or a Qt signal. qgisAuthDatabaseFilePath
Returns the path to the user authentication database file: qgis-auth.db. qgisMasterDatabaseFilePath
Returns the path to the master qgis.db file. qgisSettingsDirPath
Returns the path to the settings directory in user’s home dir qgisUserDatabaseFilePath
Returns the path to the user qgis.db file. queryKeyboardModifiers
quit
quitOnLastWindowClosed
receivers
registerOgrDrivers
Register OGR drivers ensuring this only happens once. relativePathToAbsolutePath
Converts path relative to target to an absolute path removeEventFilter
removeLibraryPath
removeNativeEventFilter
removePostedEvents
removeTranslator
renderer3DRegistry
Returns registry of available 3D renderers. rendererRegistry
Returns the application’s renderer registry, used for managing vector layer renderers. reportStyleSheet
get a standard css style sheet for reports. restoreGdalDriver
Sets the GDAL_SKIP environment variable to exclude the specified driver and then calls GDALDriverManager.AutoSkipDrivers() to unregister it. restoreOverrideCursor
screens
sendEvent
sendPostedEvents
sender
senderSignalIndex
serverResourcesPath
Returns the path to the server resources directory. sessionId
sessionKey
setActiveWindow
setApplicationDisplayName
setApplicationName
setApplicationVersion
setAttribute
setAuthDatabaseDirPath
Alters authentication data base directory path - used by 3rd party apps setAutoSipEnabled
setColorSpec
setCursorFlashTime
setCustomVariable
Set a single custom expression variable. setCustomVariables
Custom expression variables for this application. setDefaultSvgPaths
Alters default svg paths - used by 3rd party apps. setDesktopFileName
setDesktopSettingsAware
setDoubleClickInterval
setEffectEnabled
setEventDispatcher
setFallbackSessionManagementEnabled
setFileOpenEventReceiver
Set the FileOpen event receiver setFont
setGlobalStrut
setKeyboardInputInterval
setLayoutDirection
setLibraryPaths
setMaxThreads
Set maximum concurrent thread count setNullRepresentation
copydoc nullRepresentation() setObjectName
setOrganizationDomain
setOrganizationName
setOverrideCursor
setPalette
setParent
setPkgDataPath
Alters pkg data path - used by 3rd party apps setPluginPath
Alters plugin path - used by 3rd party apps setPrefixPath
Alters prefix path - used by 3rd party apps setProperty
setQuitLockEnabled
setQuitOnLastWindowClosed
setSetuidAllowed
setStartDragDistance
setStartDragTime
setStyle
setStyle(str) -> QStyle setStyleSheet
setThemeName
Set the active theme to the specified theme. setUITheme
Set the current UI theme used to style the interface. setWheelScrollLines
setWindowIcon
shortNameRegExp
Returns the short name regular expression for line edit validator showSettings
Convenience function to get a summary of the paths used in this signalsBlocked
skipGdalDriver
Sets the GDAL_SKIP environment variable to include the specified driver and then calls GDALDriverManager.AutoSkipDrivers() to unregister it. skippedGdalDrivers
Returns the list of gdal drivers that should be skipped (based on splashPath
Returns the path to the splash screen image directory. sponsorsFilePath
Returns the path to the sponsors file. srsDatabaseFilePath
Returns the path to the srs.db file. startDragDistance
startDragTime
startTimer
startingUp
style
styleSheet
svgCache
Returns the application’s SVG cache, used for caching SVG images and handling parameter replacement within SVG files. svgPaths
Returns the paths to svg directories. symbolLayerRegistry
Returns the application’s symbol layer registry, used for managing symbol layers. sync
systemEnvVars
Returns the system environment variables passed to application. taskManager
Returns the application’s task manager, used for managing application wide background task handling. testAttribute
themeName
Set the active theme to the specified theme. thread
timerEvent
topLevelAt
topLevelAt(int, int) -> QWidget topLevelWidgets
topLevelWindows
tr
translate
translatorsFilePath
Returns the path to the sponsors file. uiThemes
All themes found in ~/.qgis3/themes folder. userFullName
Returns the user’s operating system login account full display name. userLoginName
Returns the user’s operating system login account name. userStylePath
Returns the path to user’s style. userThemesFolder
Returns the path to user’s themes folder wheelScrollLines
widgetAt
widgetAt(int, int) -> QWidget windowIcon
Attributes
CapturePoint
CrossHair
CustomColor
Identify
ManyColor
NDR
NormalColor
QGIS_APPLICATION_NAME
QGIS_ORGANIZATION_DOMAIN
QGIS_ORGANIZATION_NAME
Sampler
Select
XDR
ZoomIn
ZoomOut
aboutToQuit
aboutToQuit(self) [signal] commitDataRequest
commitDataRequest(self, QSessionManager) [signal] customVariablesChanged
Emitted whenever a custom global variable changes. destroyed
destroyed(self, QObject = None) [signal] focusChanged
focusChanged(self, QWidget, QWidget) [signal] focusObjectChanged
focusObjectChanged(self, QObject) [signal] focusWindowChanged
focusWindowChanged(self, QWindow) [signal] fontDatabaseChanged
fontDatabaseChanged(self) [signal] lastWindowClosed
lastWindowClosed(self) [signal] nullRepresentationChanged
copydoc nullRepresentation() [signal] objectNameChanged
objectNameChanged(self, str) [signal] paletteChanged
paletteChanged(self, QPalette) [signal] primaryScreenChanged
primaryScreenChanged(self, QScreen) [signal] saveStateRequest
saveStateRequest(self, QSessionManager) [signal] screenAdded
screenAdded(self, QScreen) [signal] screenRemoved
screenRemoved(self, QScreen) [signal] staticMetaObject
-
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'¶
-
Sampler
= 6¶
-
Select
= 5¶
-
XDR
= 0¶
-
ZoomIn
= 0¶
-
ZoomOut
= 1¶
-
absolutePathToRelativePath
(apath: str, targetPath: str) → str¶ Converts absolute path to path relative to target
-
actionScopeRegistry
() → QgsActionScopeRegistry¶ Returns the action scope registry.
New in version 3.0.
-
activeThemePath
() → str¶ Returns the path to the currently active theme directory.
-
appIconPath
() → str¶ get application icon
-
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 a null pointer if called before initQgis
See also
New in version 3.0.
Returns the path to the authors file.
-
buildOutputPath
() → str¶ Returns path to the build output directory. Valid only when running from build directory
-
buildSourcePath
() → str¶ Returns path to the source directory. Valid only when running from build directory
-
childEvent
()¶
-
colorSchemeRegistry
() → QgsColorSchemeRegistry¶ Returns the application’s color scheme registry, used for managing color schemes.
New in version 3.0.
-
composerTemplatePaths
() → List[str]¶ Returns the paths to composer template directories
-
connectNotify
()¶
-
contributorsFilePath
() → str¶ Returns the path to the contributors file. Contributors are people who have submitted patches but don’t have commit access. *
-
createDatabase
(errorMessage: str = '') → bool¶ initialize qgis.db
-
createThemeFolder
() → bool¶ Create the users theme folder
-
customEvent
()¶
-
customVariables
() → Dict[str, Any]¶ Custom expression variables for this application. This does not include generated variables (like system name, user name etc.)
See also
QgsExpressionContextUtils.globalVariables()
New in version 3.0.
-
customVariablesChanged
¶ Emitted whenever a custom global variable changes.
New in version 3.0: [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.
-
defaultStylePath
() → str¶ Returns the path to default style (works as a starting point).
-
defaultThemePath
() → str¶ Returns the path to the default theme directory.
-
defaultThemesFolder
() → str¶ Returns the path to default themes folder from install (works as a starting point).
-
developersMapFilePath
() → str¶ Returns the path to the developers map file. The developers map was created by using leaflet framework, it shows the doc/contributors.json file.
New in version 2.7.
-
disconnectNotify
()¶
-
donorsFilePath
() → str¶ Returns the path to the donors file.
-
endian
() → QgsApplication.endian_t¶ Returns whether this machine uses big or little endian
-
class
endian_t
¶ Bases:
int
-
event
(self, event: QEvent) → bool¶ Watch for QFileOpenEvent.
-
exitQgis
()¶ deletes provider registry and map layer registry
-
fieldFormatterRegistry
() → QgsFieldFormatterRegistry¶ Get the registry of available field formatters.
-
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.
-
getThemeIcon
(name: str) → 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.
-
getThemePixmap
(name: str) → 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.
-
gpsConnectionRegistry
() → QgsGPSConnectionRegistry¶ Returns the application’s GPS connection registry, used for managing GPS connections.
New in version 3.0.
-
i18nPath
() → str¶ Returns the path to the translation directory.
-
iconPath
(iconFile: str) → str¶ Returns path to the desired icon file. First it tries to use the active theme path, then default theme path
-
iconsPath
() → str¶ Returns the path to the icons image directory.
-
initQgis
()¶ loads providers
-
instance
() → QgsApplication¶ Returns the singleton instance of the QgsApplication.
New in version 3.0.
-
isRunningFromBuildDir
() → bool¶ Indicates whether running from build directory (not installed)
-
isSignalConnected
()¶
-
layoutItemRegistry
() → QgsLayoutItemRegistry¶ Returns the application’s layout item registry, used for layout item types.
New in version 3.0.
-
libexecPath
() → str¶ Returns the path with utility executables (help viewer, crssync, …)
-
libraryPath
() → str¶ Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries
-
licenceFilePath
() → str¶ Returns the path to the licence file.
-
locale
() → str¶ Returns the QGIS locale.
New in version 3.0.
-
maxThreads
() → int¶ Get maximum concurrent thread count
New in version 2.4.
-
messageLog
() → QgsMessageLog¶ Returns the application’s message log.
New in version 3.0.
-
metadataPath
() → str¶ Returns the path to the metadata directory.
New in version 3.0.
-
notify
(self, receiver: QObject, event: QEvent) → bool¶ Catch exceptions when sending event to receiver.
-
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.
-
nullRepresentationChanged
¶ copydoc nullRepresentation() [signal]
-
osName
() → str¶ Returns a string name of the operating system QGIS is running on.
New in version 2.14.
See also
-
pageSizeRegistry
() → QgsPageSizeRegistry¶ Returns the application’s page size registry, used for managing layout page sizes.
New in version 3.0.
-
paintEffectRegistry
() → QgsPaintEffectRegistry¶ Returns the application’s paint effect registry, used for managing paint effects.
New in version 3.0.
-
pkgDataPath
() → str¶ Returns the common root path of all application data directories.
-
platform
() → str¶ Returns the QGIS platform name, e.g., “desktop” or “server”.
New in version 2.14.
See also
-
pluginLayerRegistry
() → QgsPluginLayerRegistry¶ Returns the application’s plugin layer registry, used for managing plugin layer types.
New in version 3.0.
-
pluginPath
() → str¶ Returns the path to the application plugin directory.
-
prefixPath
() → str¶ Returns the path to the application prefix directory.
-
processingRegistry
() → QgsProcessingRegistry¶ Returns the application’s processing registry, used for managing processing providers, algorithms, and various parameters and outputs.
New in version 3.0.
-
profiler
() → QgsRuntimeProfiler¶ Returns the application runtime profiler.
New in version 3.0.
-
qgisAuthDatabaseFilePath
() → str¶ Returns the path to the user authentication database file: qgis-auth.db.
-
qgisMasterDatabaseFilePath
() → str¶ Returns the path to the master qgis.db file.
-
qgisSettingsDirPath
() → str¶ Returns the path to the settings directory in user’s home dir
-
qgisUserDatabaseFilePath
() → str¶ Returns the path to the user qgis.db file.
-
receivers
()¶
-
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
-
renderer3DRegistry
() → Qgs3DRendererRegistry¶ Returns registry of available 3D renderers.
Note
not available in Python bindings
New in version 3.0.
-
rendererRegistry
() → QgsRendererRegistry¶ Returns the application’s renderer registry, used for managing vector layer renderers.
New in version 3.0.
-
reportStyleSheet
() → str¶ get a standard css style sheet for reports. Typically you will use this method by doing: QString myStyle = QgsApplication.reportStyleSheet(); textBrowserReport->document()->setDefaultStyleSheet(myStyle);
Returns: QString containing the CSS 2.1 compliant stylesheet. Note
you can use the special Qt extensions too, for example the gradient fills for backgrounds.
-
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.
-
sender
()¶
-
senderSignalIndex
()¶
-
serverResourcesPath
() → str¶ Returns the path to the server resources directory.
-
setAuthDatabaseDirPath
(authDbDirPath: str)¶ Alters authentication data base directory path - used by 3rd party apps
-
setCustomVariable
(name: str, value: Any)¶ Set a single custom expression variable.
New in version 3.0.
-
setCustomVariables
(customVariables: Dict[str, Any])¶ Custom expression variables for this application. Do not include generated variables (like system name, user name etc.)
See also
QgsExpressionContextUtils.globalVariables()
New in version 3.0.
-
setDefaultSvgPaths
(pathList: Iterable[str])¶ Alters default svg paths - used by 3rd party apps.
-
setFileOpenEventReceiver
(receiver: QObject)¶ Set the FileOpen event receiver
-
setMaxThreads
(maxThreads: int)¶ Set maximum concurrent thread count
Note
must be between 1 and #cores, -1 means use all available cores
New in version 2.4.
-
setNullRepresentation
(nullRepresentation: str)¶ copydoc nullRepresentation()
-
setPkgDataPath
(pkgDataPath: str)¶ Alters pkg data path - used by 3rd party apps
-
setPluginPath
(pluginPath: str)¶ Alters plugin path - used by 3rd party apps
-
setPrefixPath
(prefixPath: str, useDefaultPaths: bool = False)¶ Alters prefix path - used by 3rd party apps
-
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’.
-
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 – The name of the theme. Note
using an invalid theme name will reset to default
-
shortNameRegExp
() → QRegExp¶ Returns the short name regular expression for line edit validator
-
showSettings
() → str¶ Convenience function to get a summary of the paths used in this application instance useful for debugging mainly.*
-
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.
-
skippedGdalDrivers
() → List[str]¶ Returns the list of gdal drivers that should be skipped (based on GDAL_SKIP environment variable)
-
splashPath
() → str¶ Returns the path to the splash screen image directory.
-
sponsorsFilePath
() → str¶ Returns the path to the sponsors file.
-
srsDatabaseFilePath
() → str¶ Returns the path to the srs.db file.
-
svgCache
() → QgsSvgCache¶ Returns the application’s SVG cache, used for caching SVG images and handling parameter replacement within SVG files.
New in version 3.0.
-
svgPaths
() → List[str]¶ Returns the paths to svg directories.
-
symbolLayerRegistry
() → QgsSymbolLayerRegistry¶ Returns the application’s symbol layer registry, used for managing symbol layers.
New in version 3.0.
-
systemEnvVars
() → Dict[str, str]¶ Returns the system environment variables passed to application.
-
taskManager
() → QgsTaskManager¶ Returns the application’s task manager, used for managing application wide background task handling.
New in version 3.0.
-
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.
-
timerEvent
()¶
-
translatorsFilePath
() → str¶ Returns the path to the sponsors file.
-
uiThemes
() → object¶ All themes found in ~/.qgis3/themes folder. The path is to the root folder for the theme
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.
New in version 2.14.
See also
-
userLoginName
() → str¶ Returns the user’s operating system login account name.
New in version 2.14.
See also
-
userStylePath
() → str¶ Returns the path to user’s style.
-
userThemesFolder
() → str¶ Returns the path to user’s themes folder
-