Class: QgisInterface

class qgis.gui.QgisInterface

Bases: PyQt5.QtCore.QObject

Constructor

QgisInterface Abstract base class defining interfaces exposed by QgisApp and made available to plugins.

Only functionality exposed by QgisInterface can be used in plugins. This interface has to be implemented with application specific details.

QGIS implements it in QgisAppInterface class, 3rd party applications could provide their own implementation to be able to use plugins.

Enums

Methods

actionAbout

actionAddAfsLayer

Returns the native Add ArcGIS FeatureServer action.

actionAddAllToOverview

actionAddAmsLayer

Returns the native Add ArcGIS MapServer action.

actionAddFeature

Returns the native Add Feature action.

actionAddOgrLayer

actionAddPart

Returns the native Add Part action.

actionAddPgLayer

actionAddRasterLayer

actionAddRing

Returns the native Add Ring action.

actionAddToOverview

actionAddWmsLayer

actionAllEdits

actionCancelAllEdits

actionCancelEdits

actionCheckQgisVersion

actionCopyFeatures

Returns the native Copy Features action.

actionCopyLayerStyle

actionCreatePrintLayout

Create new print layout action

actionCustomProjection

actionCutFeatures

Returns the native Cut Features action.

actionDeletePart

Returns the native Delete Part action.

actionDeleteRing

Returns the native Delete Ring action.

actionDeleteSelected

Returns the native Delete Selected Features action.

actionDraw

Returns the native draw action.

actionDuplicateLayer

actionExit

Returns the Exit QGIS action.

actionFeatureAction

Returns the native run action feature action.

actionHelpContents

actionHideAllLayers

actionHideDeselectedLayers

Returns the Hide Deselected Layers action.

actionHideSelectedLayers

actionIdentify

Returns the native identify action.

actionLayerProperties

actionLayerSaveAs

actionManagePlugins

actionMapTips

Returns the native map tips action.

actionMeasure

Returns the native measure action.

actionMeasureArea

Returns the native measure area action.

actionMoveFeature

Returns the native Move Features action.

actionNewBookmark

Returns the native new bookmark action.

actionNewProject

Returns the native New Project action.

actionNewVectorLayer

actionOpenFieldCalculator

actionOpenProject

Returns the Open Project action.

actionOpenStatisticalSummary

Statistical summary action.

actionOpenTable

actionOptions

actionPan

Returns the native pan action.

actionPanToSelected

Returns the native pan to selected action.

actionPasteFeatures

Returns the native Paste Features action.

actionPasteLayerStyle

actionPluginListSeparator

actionProjectProperties

Returns the native Project Properties action.

actionQgisHomePage

actionRemoveAllFromOverview

actionRollbackAllEdits

actionRollbackEdits

actionSaveActiveLayerEdits

actionSaveAllEdits

actionSaveEdits

actionSaveMapAsImage

Returns the native Save Map as Image action.

actionSaveProject

Returns the native Save Project action.

actionSaveProjectAs

Returns the native Save Project As action.

actionSelect

Returns the native select action.

actionSelectFreehand

Returns the native select freehand action.

actionSelectPolygon

Returns the native select polygon action.

actionSelectRadius

Returns the native select radius action.

actionSelectRectangle

Returns the native select rectangle action.

actionShowAllLayers

actionShowBookmarks

Returns the native show bookmarks action.

actionShowLayoutManager

Show layout manager action

actionShowPythonDialog

actionShowSelectedLayers

actionSimplifyFeature

Returns the native Simplify/Smooth Features action.

actionSplitFeatures

Returns the native Split Features action.

actionSplitParts

Returns the native Split Parts action.

actionToggleEditing

actionToggleFullScreen

actionVertexTool

Returns the native “Vertex Tool for All Layers” action.

actionVertexToolActiveLayer

Returns the native “Vertex Tool for Active Layer” action.

actionZoomActualSize

Returns the native zoom resolution (100%) action.

actionZoomFullExtent

Returns the native zoom full extent action.

actionZoomIn

Returns the native zoom in action.

actionZoomLast

Returns the native zoom last action.

actionZoomNext

Returns the native zoom next action.

actionZoomOut

Returns the native zoom out action.

actionZoomToLayer

Returns the native zoom to layer action.

actionZoomToSelected

Returns the native zoom to selected action.

activeLayer

Returns a pointer to the active layer (layer selected in the legend)

addCustomActionForLayer

Add action to context menu for a specific layer in the layer tree.

addCustomActionForLayerType

Add action to context menu for layers in the layer tree.

addDatabaseToolBarIcon

Add an icon to the Database toolbar

addDatabaseToolBarWidget

Add a widget to the database toolbar.

addDockWidget

Adds a dock widget to the main window, in the specified dock area.

addLayerMenu

Returns a reference to the main window “Add Layer” menu.

addMeshLayer

Adds a mesh layer to the current project.

addPluginToDatabaseMenu

Add action to the Database menu

addPluginToMenu

Add action to the plugins menu

addPluginToRasterMenu

Add action to the Raster menu

addPluginToVectorMenu

Add action to the Vector menu

addPluginToWebMenu

Add action to the Web menu

addProject

Adds (opens) a project

addRasterLayer

Adds a raster layer to the current project, given a raster layer file name.

addRasterToolBarIcon

Add an icon to the Raster toolbar

addRasterToolBarWidget

Add a widget to the raster toolbar.

addToolBar

Add toolbar with specified name

addToolBarIcon

Add an icon to the plugins toolbar

addToolBarWidget

Add a widget to the plugins toolbar.

addUserInputWidget

Adds a widget to the user input tool bar.

addVectorLayer

Adds a vector layer to the current project.

addVectorToolBarIcon

Add an icon to the Vector toolbar

addVectorToolBarWidget

Add a widget to the vector toolbar.

addWebToolBarIcon

Add an icon to the Web toolbar

addWebToolBarWidget

Add a widget to the web toolbar.

addWindow

Add window to Window menu.

advancedDigitizeToolBar

Returns a reference to the main window “Advanced Digitizing” toolbar.

askForDatumTransform

Checks available datum transforms and ask user if several are available and none is chosen.

attributesToolBar

Returns a reference to the main window “Attributes” toolbar.

browserModel

Returns the application browser model.

buildStyleSheet

Generate stylesheet

cadDockWidget

Advanced digitizing dock widget

childEvent

closeMapCanvas

Closes the additional map canvas with matching name.

connectNotify

copySelectionToClipboard

Copy selected features from the layer to clipboard

createNewMapCanvas

Create a new map canvas with the specified unique name.

customEvent

dataSourceManagerToolBar

Returns a reference to the main window “Data Source Manager” toolbar.

databaseMenu

Returns a reference to the main window “Database” menu.

databaseToolBar

Returns a reference to the main window “Database” toolbar.

defaultStyleSheetFont

Returns a reference font for initial qApp (may not be same as QgisApp)

defaultStyleSheetOptions

Returns changeable options built from settings and/or defaults

deregisterLocatorFilter

Deregisters a locator filter from the app’s locator bar and deletes it.

digitizeToolBar

Returns a reference to the main window “Digitize” toolbar.

disconnectNotify

editMenu

Returns a reference to the main window “Edit” menu.

editableLayers

Returns vector layers in edit mode

fileToolBar

Returns a reference to the main window “File” toolbar.

firstRightStandardMenu

Returns a reference to the right most standard menu, which is usually the last menu item before the “Help” menu.

getFeatureForm

Returns a feature form for a given feature.

helpMenu

Returns a reference to the main window “Help” menu.

helpToolBar

Returns a reference to the main window “Help” toolbar.

iconSize

Returns the toolbar icon size.

insertAddLayerAction

Add “add layer” action to layer menu

invalidateLocatorResults

Invalidate results from the locator filter.

isSignalConnected

layerMenu

Returns a reference to the main window “Layer” menu.

layerToolBar

Returns a reference to the main window “Layer” toolbar.

layerTreeCanvasBridge

Returns a pointer to the layer tree canvas bridge

layerTreeView

mainWindow

Returns a pointer to the main window (instance of QgisApp in case of QGIS)

mapCanvas

Returns a pointer to the map canvas

mapCanvases

Returns a list of all map canvases open in the app.

mapNavToolToolBar

Returns a reference to the main window “Map Navigation” toolbar.

messageBar

Returns the message bar of the main app

messageTimeout

Returns the timeout for timed messages: default of 5 seconds

newLayerMenu

Returns a reference to the main window “Create New Layer” menu.

newProject

Starts a new blank project

openFeatureForm

Opens a new feature form.

openLayoutDesigner

Opens a new layout designer dialog for the specified layout, or brings an already open designer window to the foreground if one is already created for the layout.

openLayoutDesigners

Returns all currently open layout designers.

openMessageLog

Opens the message log dock widget.

openURL

Open a url in the users browser.

pasteFromClipboard

Paste features from clipboard to the layer

pluginManagerInterface

pluginMenu

Returns a reference to the main window “Plugin” menu.

pluginToolBar

Returns a reference to the main window “Plugin” toolbar.

preloadForm

This method is only needed when using a UI form with a custom widget plugin and calling openFeatureForm or getFeatureForm from Python (PyQt) and you haven’t used the info tool first.

projectMenu

Returns a reference to the main window “Project” menu.

rasterMenu

Returns a reference to the main window “Raster” menu.

rasterToolBar

Returns a reference to the main window “Raster” toolbar.

receivers

registerCustomDropHandler

Register a new custom drop handler.

registerCustomLayoutDropHandler

Register a new custom drop handler for layout windows.

registerLocatorFilter

Registers a locator filter for the app’s locator bar.

registerMainWindowAction

Register action to the shortcuts manager so its shortcut can be changed in GUI

registerMapLayerConfigWidgetFactory

Register a new tab in the vector layer properties dialog.

registerOptionsWidgetFactory

Register a new tab in the options dialog.

reloadConnections

Triggered when connections have changed.

removeAddLayerAction

Remove “add layer” action from layer menu

removeCustomActionForLayerType

Remove action for layers in the layer tree previously added with addCustomActionForLayerType()

removeDatabaseToolBarIcon

Remove an action (icon) from the Database toolbar

removeDockWidget

Removes the specified dock widget from main window (without deleting it).

removePluginDatabaseMenu

Remove action from the Database menu

removePluginMenu

Remove action from the plugins menu

removePluginRasterMenu

Remove action from the Raster menu

removePluginVectorMenu

Remove action from the Vector menu

removePluginWebMenu

Remove action from the Web menu

removeRasterToolBarIcon

Remove an action (icon) from the Raster toolbar

removeToolBarIcon

Remove an action (icon) from the plugin toolbar

removeVectorToolBarIcon

Remove an action (icon) from the Vector toolbar

removeWebToolBarIcon

Remove an action (icon) from the Web toolbar

removeWindow

Remove window from Window menu.

saveStyleSheetOptions

Save changed default option keys/values to user settings

sender

senderSignalIndex

setActiveLayer

Set the active layer (layer gets selected in the legend) returns True if the layer exists, False otherwise

settingsMenu

Returns a reference to the main window “Settings” menu.

shapeDigitizeToolBar

Returns a reference to the main window “Shape Digitizing” toolbar.

showAttributeTable

Open attribute table dialog

showLayerProperties

Open layer properties dialog

showLayoutManager

Opens the layout manager dialog.

showOptionsDialog

Opens the options dialog.

statusBarIface

Returns a pointer to the app’s status bar interface.

takeAppScreenShots

Take screenshots for user documentation

timerEvent

unregisterCustomDropHandler

Unregister a previously registered custom drop handler.

unregisterCustomLayoutDropHandler

Unregister a previously registered custom drop handler for layout windows.

unregisterMainWindowAction

Unregister a previously registered action.

unregisterMapLayerConfigWidgetFactory

Unregister a previously registered tab in the vector layer properties dialog.

unregisterOptionsWidgetFactory

Unregister a previously registered tab in the options dialog.

vectorLayerTools

Access the vector layer tools instance.

vectorMenu

Returns a reference to the main window “Vector” menu.

vectorToolBar

Returns a reference to the main window “Vector” toolbar.

viewMenu

Returns a reference to the main window “View” menu.

webMenu

Returns a reference to the main window “Web” menu.

webToolBar

Returns a reference to the main window “Web” toolbar.

windowMenu

Returns a reference to the main window “Window” menu.

zoomFull

Zooms to the full extent of all map layers.

zoomToActiveLayer

Zooms to extent of the active layer.

zoomToNext

Zooms to the next view extent.

zoomToPrevious

Zooms to the previous view extent.

Signals

currentLayerChanged

Emitted whenever current (selected) layer changes.

currentThemeChanged

Emitted when the current theme is changed so plugins can change their tool button icons.

initializationCompleted

Emitted when the initialization is complete.

layerSavedAs

Emitted when a layer has been saved using save as.

layoutDesignerClosed

Emitted after a layout designer window is closed.

layoutDesignerOpened

Emitted when a new layout designer has been opened.

layoutDesignerWillBeClosed

Emitted before a layout designer is going to be closed and deleted.

newProjectCreated

Emitted when starting an entirely new project.

projectRead

Emitted when a project file is successfully read.

Attributes

actionAbout(self) → QAction
actionAddAfsLayer(self) → QAction

Returns the native Add ArcGIS FeatureServer action.

actionAddAllToOverview(self) → QAction
actionAddAmsLayer(self) → QAction

Returns the native Add ArcGIS MapServer action.

actionAddFeature(self) → QAction

Returns the native Add Feature action.

actionAddOgrLayer(self) → QAction
actionAddPart(self) → QAction

Returns the native Add Part action.

actionAddPgLayer(self) → QAction
actionAddRasterLayer(self) → QAction
actionAddRing(self) → QAction

Returns the native Add Ring action.

actionAddToOverview(self) → QAction
actionAddWmsLayer(self) → QAction
actionAllEdits(self) → QAction
actionCancelAllEdits(self) → QAction
actionCancelEdits(self) → QAction
actionCheckQgisVersion(self) → QAction
actionCopyFeatures(self) → QAction

Returns the native Copy Features action.

actionCopyLayerStyle(self) → QAction
actionCreatePrintLayout(self) → QAction

Create new print layout action

actionCustomProjection(self) → QAction
actionCutFeatures(self) → QAction

Returns the native Cut Features action.

actionDeletePart(self) → QAction

Returns the native Delete Part action.

actionDeleteRing(self) → QAction

Returns the native Delete Ring action.

actionDeleteSelected(self) → QAction

Returns the native Delete Selected Features action.

actionDraw(self) → QAction

Returns the native draw action.

actionDuplicateLayer(self) → QAction
actionExit(self) → QAction

Returns the Exit QGIS action.

actionFeatureAction(self) → QAction

Returns the native run action feature action. Call trigger() on it to set the default run feature action map tool.

actionHelpContents(self) → QAction
actionHideAllLayers(self) → QAction
actionHideDeselectedLayers(self) → QAction

Returns the Hide Deselected Layers action.

New in version 3.0.

actionHideSelectedLayers(self) → QAction
actionIdentify(self) → QAction

Returns the native identify action. Call trigger() on it to set the default identify map tool.

actionLayerProperties(self) → QAction
actionLayerSaveAs(self) → QAction
actionManagePlugins(self) → QAction
actionMapTips(self) → QAction

Returns the native map tips action. Call trigger() on it to toggle map tips.

actionMeasure(self) → QAction

Returns the native measure action. Call trigger() on it to set the default measure map tool.

actionMeasureArea(self) → QAction

Returns the native measure area action. Call trigger() on it to set the default measure area map tool.

actionMoveFeature(self) → QAction

Returns the native Move Features action.

actionNewBookmark(self) → QAction

Returns the native new bookmark action. Call trigger() on it to open the new bookmark dialog.

actionNewProject(self) → QAction

Returns the native New Project action.

actionNewVectorLayer(self) → QAction
actionOpenFieldCalculator(self) → QAction
actionOpenProject(self) → QAction

Returns the Open Project action.

actionOpenStatisticalSummary(self) → QAction

Statistical summary action.

New in version 3.0.

actionOpenTable(self) → QAction
actionOptions(self) → QAction
actionPan(self) → QAction

Returns the native pan action. Call trigger() on it to set the default pan map tool.

actionPanToSelected(self) → QAction

Returns the native pan to selected action. Call trigger() on it to pan the map canvas to the selection.

actionPasteFeatures(self) → QAction

Returns the native Paste Features action.

actionPasteLayerStyle(self) → QAction
actionPluginListSeparator(self) → QAction
actionProjectProperties(self) → QAction

Returns the native Project Properties action.

actionQgisHomePage(self) → QAction
actionRemoveAllFromOverview(self) → QAction
actionRollbackAllEdits(self) → QAction
actionRollbackEdits(self) → QAction
actionSaveActiveLayerEdits(self) → QAction
actionSaveAllEdits(self) → QAction
actionSaveEdits(self) → QAction
actionSaveMapAsImage(self) → QAction

Returns the native Save Map as Image action.

actionSaveProject(self) → QAction

Returns the native Save Project action.

actionSaveProjectAs(self) → QAction

Returns the native Save Project As action.

actionSelect(self) → QAction

Returns the native select action. Call trigger() on it to set the default select map tool.

actionSelectFreehand(self) → QAction

Returns the native select freehand action. Call trigger() on it to set the default select freehand map tool.

actionSelectPolygon(self) → QAction

Returns the native select polygon action. Call trigger() on it to set the default select polygon map tool.

actionSelectRadius(self) → QAction

Returns the native select radius action. Call trigger() on it to set the default select radius map tool.

actionSelectRectangle(self) → QAction

Returns the native select rectangle action. Call trigger() on it to set the default select rectangle map tool.

actionShowAllLayers(self) → QAction
actionShowBookmarks(self) → QAction

Returns the native show bookmarks action. Call trigger() on it to open the bookmarks dialog.

actionShowLayoutManager(self) → QAction

Show layout manager action

actionShowPythonDialog(self) → QAction
actionShowSelectedLayers(self) → QAction
actionSimplifyFeature(self) → QAction

Returns the native Simplify/Smooth Features action.

actionSplitFeatures(self) → QAction

Returns the native Split Features action.

actionSplitParts(self) → QAction

Returns the native Split Parts action.

actionToggleEditing(self) → QAction
actionToggleFullScreen(self) → QAction
actionVertexTool(self) → QAction

Returns the native “Vertex Tool for All Layers” action.

actionVertexToolActiveLayer(self) → QAction

Returns the native “Vertex Tool for Active Layer” action.

New in version 3.6.

actionZoomActualSize(self) → QAction

Returns the native zoom resolution (100%) action. Call trigger() on it to zoom to actual size.

actionZoomFullExtent(self) → QAction

Returns the native zoom full extent action. Call trigger() on it to zoom to the full extent.

actionZoomIn(self) → QAction

Returns the native zoom in action. Call trigger() on it to set the default zoom in map tool.

actionZoomLast(self) → QAction

Returns the native zoom last action. Call trigger() on it to zoom to last.

actionZoomNext(self) → QAction

Returns the native zoom next action. Call trigger() on it to zoom to next.

actionZoomOut(self) → QAction

Returns the native zoom out action. Call trigger() on it to set the default zoom out map tool.

actionZoomToLayer(self) → QAction

Returns the native zoom to layer action. Call trigger() on it to zoom to the active layer.

actionZoomToSelected(self) → QAction

Returns the native zoom to selected action. Call trigger() on it to zoom to the current selection.

activeLayer(self) → QgsMapLayer

Returns a pointer to the active layer (layer selected in the legend)

addCustomActionForLayer(self, action: QAction, layer: QgsMapLayer)

Add action to context menu for a specific layer in the layer tree. It is necessary to first call addCustomActionForLayerType() with allLayers=false in order for this method to have any effect.

addCustomActionForLayerType(self, action: QAction, menu: str, type: QgsMapLayerType, allLayers: bool)

Add action to context menu for layers in the layer tree. If allLayers is True, then the action will be available for all layers of given type, otherwise the action will be available only for specific layers added with addCustomActionForLayer() after this call.

If menu argument is not empty, the action will be also added to a menu within the main window, creating menu with the given name if it does not exist yet.

addDatabaseToolBarIcon(self, qAction: QAction) → int

Add an icon to the Database toolbar

addDatabaseToolBarWidget(self, widget: QWidget) → QAction

Add a widget to the database toolbar. To remove this widget again, call removeDatabaseToolBarIcon() with the returned QAction.

Parameters

widget – widget to add. The toolbar will take ownership of this widget

Returns

the QAction you can use to remove this widget from the toolbar

addDockWidget(self, area: Qt.DockWidgetArea, dockwidget: QDockWidget)

Adds a dock widget to the main window, in the specified dock area.

addLayerMenu(self) → QMenu

Returns a reference to the main window “Add Layer” menu.

New in version 2.5.

addMeshLayer(self, url: str, baseName: str, providerKey: str) → QgsMeshLayer

Adds a mesh layer to the current project.

addPluginToDatabaseMenu(self, name: str, action: QAction)

Add action to the Database menu

addPluginToMenu(self, name: str, action: QAction)

Add action to the plugins menu

addPluginToRasterMenu(self, name: str, action: QAction)

Add action to the Raster menu

addPluginToVectorMenu(self, name: str, action: QAction)

Add action to the Vector menu

addPluginToWebMenu(self, name: str, action: QAction)

Add action to the Web menu

addProject(self, project: str) → bool

Adds (opens) a project

addRasterLayer(self, rasterLayerPath: str, baseName: str = '') → QgsRasterLayer

Adds a raster layer to the current project, given a raster layer file name.

addRasterLayer(self, url: str, layerName: str, providerKey: str) -> QgsRasterLayer Adds a raster layer to the current project, from the specified raster data provider.

addRasterToolBarIcon(self, qAction: QAction) → int

Add an icon to the Raster toolbar

addRasterToolBarWidget(self, widget: QWidget) → QAction

Add a widget to the raster toolbar. To remove this widget again, call removeRasterToolBarIcon() with the returned QAction.

Parameters

widget – widget to add. The toolbar will take ownership of this widget

Returns

the QAction you can use to remove this widget from the toolbar

addToolBar(self, name: str) → QToolBar

Add toolbar with specified name

addToolBar(self, toolbar: QToolBar, area: Qt.ToolBarArea = Qt.TopToolBarArea) Add a toolbar

New in version 2.3.

addToolBarIcon(self, qAction: QAction) → int

Add an icon to the plugins toolbar

addToolBarWidget(self, widget: QWidget) → QAction

Add a widget to the plugins toolbar. To remove this widget again, call removeToolBarIcon() with the returned QAction.

Parameters

widget – widget to add. The toolbar will take ownership of this widget

Returns

the QAction you can use to remove this widget from the toolbar

addUserInputWidget(self, widget: QWidget)

Adds a widget to the user input tool bar.

addVectorLayer(self, vectorLayerPath: str, baseName: str, providerKey: str) → QgsVectorLayer

Adds a vector layer to the current project.

addVectorToolBarIcon(self, qAction: QAction) → int

Add an icon to the Vector toolbar

addVectorToolBarWidget(self, widget: QWidget) → QAction

Add a widget to the vector toolbar. To remove this widget again, call removeVectorToolBarIcon() with the returned QAction.

Parameters

widget – widget to add. The toolbar will take ownership of this widget

Returns

the QAction you can use to remove this widget from the toolbar

addWebToolBarIcon(self, qAction: QAction) → int

Add an icon to the Web toolbar

addWebToolBarWidget(self, widget: QWidget) → QAction

Add a widget to the web toolbar. To remove this widget again, call removeWebToolBarIcon() with the returned QAction.

Parameters

widget – widget to add. The toolbar will take ownership of this widget

Returns

the QAction you can use to remove this widget from the toolbar

addWindow(self, action: QAction)

Add window to Window menu. The action title is the window title and the action should raise, unminimize and activate the window.

advancedDigitizeToolBar(self) → QToolBar

Returns a reference to the main window “Advanced Digitizing” toolbar.

askForDatumTransform(self, sourceCrs: QgsCoordinateReferenceSystem, destinationCrs: QgsCoordinateReferenceSystem) → bool

Checks available datum transforms and ask user if several are available and none is chosen. Dialog is shown only if global option is set accordingly.

Returns

True if a datum transform has been specifically chosen by user or only one is available.

New in version 3.0.

attributesToolBar(self) → QToolBar

Returns a reference to the main window “Attributes” toolbar.

browserModel(self) → QgsBrowserModel

Returns the application browser model. Using this shared model is more efficient than creating a new browser model for every use.

New in version 3.4.

buildStyleSheet(self, opts: Dict[str, Any])

Generate stylesheet

Parameters

opts – generated default option values, or a changed copy of them

cadDockWidget(self) → QgsAdvancedDigitizingDockWidget

Advanced digitizing dock widget

New in version 2.12.

childEvent()
closeMapCanvas(self, name: str)

Closes the additional map canvas with matching name.

New in version 3.0.

connectNotify()
copySelectionToClipboard(self, QgsMapLayer)

Copy selected features from the layer to clipboard

New in version 3.0.

createNewMapCanvas(self, name: str) → QgsMapCanvas

Create a new map canvas with the specified unique name.

See also

closeMapCanvas()

New in version 3.0.

currentLayerChanged

Emitted whenever current (selected) layer changes. The pointer to layer can be None if no layer is selected. [signal]

currentThemeChanged

Emitted when the current theme is changed so plugins can change their tool button icons.

New in version 3.0: [signal]

customEvent()
dataSourceManagerToolBar(self) → QToolBar

Returns a reference to the main window “Data Source Manager” toolbar.

New in version 3.4.

databaseMenu(self) → QMenu

Returns a reference to the main window “Database” menu.

databaseToolBar(self) → QToolBar

Returns a reference to the main window “Database” toolbar.

defaultStyleSheetFont(self) → QFont

Returns a reference font for initial qApp (may not be same as QgisApp)

defaultStyleSheetOptions(self) → Dict[str, Any]

Returns changeable options built from settings and/or defaults

deregisterLocatorFilter(self, filter: QgsLocatorFilter)

Deregisters a locator filter from the app’s locator bar and deletes it. Calling this will block whilst any currently running query is terminated.

Plugins which register filters to the locator bar must take care to correctly call deregisterLocatorFilter() to deregister their filters upon plugin unload to avoid crashes.

New in version 3.0.

digitizeToolBar(self) → QToolBar

Returns a reference to the main window “Digitize” toolbar.

disconnectNotify()
editMenu(self) → QMenu

Returns a reference to the main window “Edit” menu.

editableLayers(self, modified: bool = False) → List[QgsMapLayer]

Returns vector layers in edit mode

Parameters

modified – whether to return only layers that have been modified

Returns

list of layers in legend order, or empty list

fileToolBar(self) → QToolBar

Returns a reference to the main window “File” toolbar.

firstRightStandardMenu(self) → QMenu

Returns a reference to the right most standard menu, which is usually the last menu item before the “Help” menu.

This can be used to insert additional top-level menus into their correct position BEFORE the help menu.

getFeatureForm(self, l: QgsVectorLayer, f: QgsFeature) → QgsAttributeDialog

Returns a feature form for a given feature.

Parameters
  • l – The layer for which the dialog will be created

  • f – The feature for which the dialog will be created

Returns

A feature form

helpMenu(self) → QMenu

Returns a reference to the main window “Help” menu.

helpToolBar(self) → QToolBar

Returns a reference to the main window “Help” toolbar.

iconSize(self, dockedToolbar: bool = False) → QSize

Returns the toolbar icon size. If dockedToolbar is True, the icon size for toolbars contained within docks is returned.

initializationCompleted

Emitted when the initialization is complete. [signal]

insertAddLayerAction(self, action: QAction)

Add “add layer” action to layer menu

invalidateLocatorResults(self)

Invalidate results from the locator filter.

This might be useful if the configuration of the filter changed without going through main application settings.

New in version 3.2.

isSignalConnected()
layerMenu(self) → QMenu

Returns a reference to the main window “Layer” menu.

layerSavedAs

Emitted when a layer has been saved using save as.

New in version 2.7: [signal]

layerToolBar(self) → QToolBar

Returns a reference to the main window “Layer” toolbar.

layerTreeCanvasBridge(self) → QgsLayerTreeMapCanvasBridge

Returns a pointer to the layer tree canvas bridge

New in version 2.12.

layerTreeView(self) → QgsLayerTreeView
layoutDesignerClosed

Emitted after a layout designer window is closed.

New in version 3.0: [signal]

layoutDesignerOpened

Emitted when a new layout designer has been opened.

New in version 3.0: [signal]

layoutDesignerWillBeClosed

Emitted before a layout designer is going to be closed and deleted.

New in version 3.0: [signal]

mainWindow(self) → QWidget

Returns a pointer to the main window (instance of QgisApp in case of QGIS)

mapCanvas(self) → QgsMapCanvas

Returns a pointer to the map canvas

mapCanvases(self) → List[QgsMapCanvas]

Returns a list of all map canvases open in the app.

New in version 3.0.

mapNavToolToolBar(self) → QToolBar

Returns a reference to the main window “Map Navigation” toolbar.

messageBar(self) → QgsMessageBar

Returns the message bar of the main app

messageTimeout(self) → int

Returns the timeout for timed messages: default of 5 seconds

newLayerMenu(self) → QMenu

Returns a reference to the main window “Create New Layer” menu.

newProject(self, promptToSaveFlag: bool = False)

Starts a new blank project

newProjectCreated

Emitted when starting an entirely new project.

Note

This is similar to projectRead(); plugins might want to be notified that they’re in a new project. Yes, projectRead() could have been overloaded to be used in the case of new projects instead. However, it’s probably more semantically correct to have an entirely separate signal for when this happens. [signal]

openFeatureForm(self, l: QgsVectorLayer, f: QgsFeature, updateFeatureOnly: bool = False, showModal: bool = True) → bool

Opens a new feature form. Returns true if dialog was accepted (if shown modal, True otherwise).

Parameters
  • l – vector layer

  • f – feature to show/modify

  • updateFeatureOnly – only update the feature update (don’t change any attributes of the layer) [UNUSED]

  • showModal – if True, will wait for the dialog to be executed (only shown otherwise)

openLayoutDesigner(self, layout: QgsMasterLayoutInterface) → QgsLayoutDesignerInterface

Opens a new layout designer dialog for the specified layout, or brings an already open designer window to the foreground if one is already created for the layout.

New in version 3.0.

openLayoutDesigners(self) → List[QgsLayoutDesignerInterface]

Returns all currently open layout designers.

New in version 3.0.

openMessageLog(self)

Opens the message log dock widget.

openURL(self, url: str, useQgisDocDirectory: bool = True)

Open a url in the users browser. By default the QGIS doc directory is used as the base for the URL. To open a URL that is not relative to the installed QGIS documentation, set useQgisDocDirectory to False.

Parameters
  • url – URL to open

  • useQgisDocDirectory – If True, the URL will be formed by concatenating url to the QGIS documentation directory path (prefix/share/doc)

Deprecated since version Use: QDesktopServices instead

pasteFromClipboard(self, QgsMapLayer)

Paste features from clipboard to the layer

New in version 3.0.

pluginManagerInterface(self) → QgsPluginManagerInterface
pluginMenu(self) → QMenu

Returns a reference to the main window “Plugin” menu.

pluginToolBar(self) → QToolBar

Returns a reference to the main window “Plugin” toolbar.

preloadForm(self, uifile: str)

This method is only needed when using a UI form with a custom widget plugin and calling openFeatureForm or getFeatureForm from Python (PyQt) and you haven’t used the info tool first. Python will crash bringing QGIS with it if the custom form is not loaded from a C++ method call.

This method uses a QTimer to call QUiLoader in order to load the form via C++. You only need to call this once. After that you can call openFeatureForm/getFeatureForm like usual.

More information here: http://qt-project.org/forums/viewthread/27098

projectMenu(self) → QMenu

Returns a reference to the main window “Project” menu.

projectRead

Emitted when a project file is successfully read.

Note

This is useful for plugins that store properties with project files. A plugin can connect to this signal. When it is emitted, the plugin knows to then check the project properties for any relevant state. [signal]

rasterMenu(self) → QMenu

Returns a reference to the main window “Raster” menu.

rasterToolBar(self) → QToolBar

Returns a reference to the main window “Raster” toolbar.

receivers()
registerCustomDropHandler(self, handler: QgsCustomDropHandler)

Register a new custom drop handler.

Note

Ownership of the factory is not transferred, and the factory must be unregistered when plugin is unloaded.

New in version 3.0.

registerCustomLayoutDropHandler(self, handler: QgsLayoutCustomDropHandler)

Register a new custom drop handler for layout windows.

Note

Ownership of the factory is not transferred, and the factory must be unregistered when plugin is unloaded.

New in version 3.0.

registerLocatorFilter(self, filter: QgsLocatorFilter)

Registers a locator filter for the app’s locator bar. Ownership of the filter is transferred to the locator.

Warning

Plugins which register filters to the locator bar must take care to correctly call deregisterLocatorFilter() and deregister their filters upon plugin unload to avoid crashes.

New in version 3.0.

registerMainWindowAction(self, action: QAction, defaultShortcut: str) → bool

Register action to the shortcuts manager so its shortcut can be changed in GUI

registerMapLayerConfigWidgetFactory(self, factory: QgsMapLayerConfigWidgetFactory)

Register a new tab in the vector layer properties dialog.

Note

Ownership of the factory is not transferred, and the factory must be unregistered when plugin is unloaded.

New in version 2.16.

registerOptionsWidgetFactory(self, factory: QgsOptionsWidgetFactory)

Register a new tab in the options dialog.

Note

Ownership of the factory is not transferred, and the factory must be unregistered when plugin is unloaded.

New in version 3.0.

reloadConnections(self)

Triggered when connections have changed. This calls reloadConnections in the main application and triggers a signal that is forwarded to the GUI elements that needs to be updated (i.e. the source select dialogs and the browser widgets)

New in version 3.0.

removeAddLayerAction(self, action: QAction)

Remove “add layer” action from layer menu

removeCustomActionForLayerType(self, action: QAction) → bool

Remove action for layers in the layer tree previously added with addCustomActionForLayerType()

removeDatabaseToolBarIcon(self, qAction: QAction)

Remove an action (icon) from the Database toolbar

removeDockWidget(self, dockwidget: QDockWidget)

Removes the specified dock widget from main window (without deleting it).

See also

addDockWidget()

removePluginDatabaseMenu(self, name: str, action: QAction)

Remove action from the Database menu

removePluginMenu(self, name: str, action: QAction)

Remove action from the plugins menu

removePluginRasterMenu(self, name: str, action: QAction)

Remove action from the Raster menu

removePluginVectorMenu(self, name: str, action: QAction)

Remove action from the Vector menu

removePluginWebMenu(self, name: str, action: QAction)

Remove action from the Web menu

removeRasterToolBarIcon(self, qAction: QAction)

Remove an action (icon) from the Raster toolbar

removeToolBarIcon(self, qAction: QAction)

Remove an action (icon) from the plugin toolbar

removeVectorToolBarIcon(self, qAction: QAction)

Remove an action (icon) from the Vector toolbar

removeWebToolBarIcon(self, qAction: QAction)

Remove an action (icon) from the Web toolbar

removeWindow(self, action: QAction)

Remove window from Window menu. Calling this is necessary only for windows which are hidden rather than deleted when closed.

saveStyleSheetOptions(self, opts: Dict[str, Any])

Save changed default option keys/values to user settings

sender()
senderSignalIndex()
setActiveLayer(self, QgsMapLayer) → bool

Set the active layer (layer gets selected in the legend) returns True if the layer exists, False otherwise

settingsMenu(self) → QMenu

Returns a reference to the main window “Settings” menu.

shapeDigitizeToolBar(self) → QToolBar

Returns a reference to the main window “Shape Digitizing” toolbar.

New in version 3.0.

showAttributeTable(self, l: QgsVectorLayer, filterExpression: str = '') → QDialog

Open attribute table dialog

showLayerProperties(self, l: QgsMapLayer)

Open layer properties dialog

showLayoutManager(self)

Opens the layout manager dialog.

New in version 3.0.

showOptionsDialog(self, parent: QWidget = None, currentPage: str = '')

Opens the options dialog. The currentPage argument can be used to force the dialog to open at a specific page.

New in version 3.0.

statusBarIface(self) → QgsStatusBar

Returns a pointer to the app’s status bar interface. This should be used for interacting and adding widgets and messages to the app’s status bar (do not use the native Qt statusBar() method).

New in version 3.0.

takeAppScreenShots(self, saveDirectory: str, categories: int = 0)

Take screenshots for user documentation

Parameters
  • saveDirectory – path where the screenshots will be saved

  • categories – an int as a flag value of QgsAppScreenShots.Categories

New in version 3.4.

timerEvent()
unregisterCustomDropHandler(self, handler: QgsCustomDropHandler)

Unregister a previously registered custom drop handler.

New in version 3.0.

unregisterCustomLayoutDropHandler(self, handler: QgsLayoutCustomDropHandler)

Unregister a previously registered custom drop handler for layout windows.

New in version 3.0.

unregisterMainWindowAction(self, action: QAction) → bool

Unregister a previously registered action. (e.g. when plugin is going to be unloaded)

unregisterMapLayerConfigWidgetFactory(self, factory: QgsMapLayerConfigWidgetFactory)

Unregister a previously registered tab in the vector layer properties dialog.

New in version 2.16.

unregisterOptionsWidgetFactory(self, factory: QgsOptionsWidgetFactory)

Unregister a previously registered tab in the options dialog.

New in version 3.0.

vectorLayerTools(self) → QgsVectorLayerTools

Access the vector layer tools instance. With the help of this you can access methods like addFeature, startEditing or stopEditing while giving the user the appropriate dialogs.

Returns

An instance of the vector layer tools

vectorMenu(self) → QMenu

Returns a reference to the main window “Vector” menu.

vectorToolBar(self) → QToolBar

Returns a reference to the main window “Vector” toolbar.

viewMenu(self) → QMenu

Returns a reference to the main window “View” menu.

webMenu(self) → QMenu

Returns a reference to the main window “Web” menu.

webToolBar(self) → QToolBar

Returns a reference to the main window “Web” toolbar.

windowMenu(self) → QMenu

Returns a reference to the main window “Window” menu.

zoomFull(self)

Zooms to the full extent of all map layers.

zoomToActiveLayer(self)

Zooms to extent of the active layer.

zoomToNext(self)

Zooms to the next view extent.

zoomToPrevious(self)

Zooms to the previous view extent.