Class: QgsMapLayerComboBox¶
- class qgis.gui.QgsMapLayerComboBox¶
Bases:
PyQt5.QtWidgets.QComboBox
The
QgsMapLayerComboBox
class is a combo box which displays the list of layersNew in version 2.3.
QgsMapLayerComboBox(parent: QWidget = None)
QgsMapLayerComboBox
creates a combo box to display the list of layers (currently in the registry). The layers can be filtered and/or ordered.Methods
Returns the list of additional (non map layer) items included at the end of the combo box.
Returns the list of additional layers added to the combobox.
Returns
True
if the combo box allows the empty layer ("not set") choice.Returns the current layer selected in the combo box.
- param event:
- param event:
- param event:
returns the list of excepted layers
Returns the list of data providers which are excluded from the combobox.
currently used filter on list layers
- param i:
Returns the layer currently shown at the specified index within the combo box.
- param e:
Sets a list of additional (non map layer) items to include at the end of the combobox.
Sets a list of additional
layers
to include in the combobox.Sets whether an optional empty layer ("not set") option is shown in the combo box.
except a list of layers not to be listed
Sets a list of data providers which should be excluded from the combobox.
setFilters allows filtering according to layer type and/or geometry type.
setLayer set the current layer selected in the combo
Sets whether the CRS of layers is also included in the combo box text.
Returns
True
if the combo box shows the layer's CRS.Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
- actionEvent(self, QActionEvent)¶
- additionalItems(self) List[str] ¶
Returns the list of additional (non map layer) items included at the end of the combo box.
See also
New in version 3.0.
- Return type:
List[str]
- additionalLayers(self) List[QgsMapLayer] ¶
Returns the list of additional layers added to the combobox.
See also
New in version 3.22.
- Return type:
List[QgsMapLayer]
- allowEmptyLayer(self) bool ¶
Returns
True
if the combo box allows the empty layer (“not set”) choice.See also
New in version 3.0.
- Return type:
bool
- changeEvent(self, QEvent)¶
- childEvent(self, QChildEvent)¶
- closeEvent(self, QCloseEvent)¶
- connectNotify(self, QMetaMethod)¶
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- currentLayer(self) QgsMapLayer ¶
Returns the current layer selected in the combo box.
See also
- Return type:
- customEvent(self, QEvent)¶
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)¶
- disconnectNotify(self, QMetaMethod)¶
- dragEnterEvent(self, event: QDragEnterEvent)¶
- Parameters:
event (QDragEnterEvent) –
- dragLeaveEvent(self, event: QDragLeaveEvent)¶
- Parameters:
event (QDragLeaveEvent) –
- dragMoveEvent(self, QDragMoveEvent)¶
- dropEvent(self, event: QDropEvent)¶
- Parameters:
event (QDropEvent) –
- enterEvent(self, QEvent)¶
- exceptedLayerList(self) List[QgsMapLayer] ¶
returns the list of excepted layers
- Return type:
List[QgsMapLayer]
- excludedProviders(self) List[str] ¶
Returns the list of data providers which are excluded from the combobox.
See also
New in version 3.0.
- Return type:
List[str]
- filters(self) QgsMapLayerProxyModel.Filters ¶
currently used filter on list layers
- Return type:
- focusInEvent(self, QFocusEvent)¶
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, bool) bool ¶
- focusOutEvent(self, QFocusEvent)¶
- focusPreviousChild(self) bool ¶
- hideEvent(self, QHideEvent)¶
- indexChanged(self, i: int)¶
- Parameters:
i (int) –
- initPainter(self, QPainter)¶
- initStyleOption(self, QStyleOptionComboBox)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- isSignalConnected(self, QMetaMethod) bool ¶
- keyPressEvent(self, QKeyEvent)¶
- keyReleaseEvent(self, QKeyEvent)¶
- layer(self, layerIndex: int) QgsMapLayer ¶
Returns the layer currently shown at the specified index within the combo box.
- Parameters:
layerIndex (int) – position of layer to return
See also
New in version 2.10.
- Return type:
- layerChanged¶
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
- leaveEvent(self, QEvent)¶
- metric(self, QPaintDevice.PaintDeviceMetric) int ¶
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, QMouseEvent)¶
- mouseReleaseEvent(self, QMouseEvent)¶
- moveEvent(self, QMoveEvent)¶
- nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int] ¶
- paintEvent(self, e: QPaintEvent)¶
- Parameters:
e (QPaintEvent) –
- receivers(self, PYQT_SIGNAL) int ¶
- resizeEvent(self, QResizeEvent)¶
- rowsChanged(self)¶
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setAdditionalItems(self, items: Iterable[str])¶
Sets a list of additional (non map layer) items to include at the end of the combobox. These may represent additional layers such as layers which are not included in the map layer registry, or paths to layers which have not yet been loaded into QGIS.
See also
New in version 3.0.
- Parameters:
items (Iterable[str]) –
- setAdditionalLayers(self, layers: Iterable[QgsMapLayer])¶
Sets a list of additional
layers
to include in the combobox.This method allows adding additional layers, which are not part of a project’s layers, into the combobox.
See also
New in version 3.22.
- Parameters:
layers (Iterable[QgsMapLayer]) –
- setAllowEmptyLayer(self, allowEmpty: bool, text: str = '', icon: QIcon = QIcon())¶
Sets whether an optional empty layer (“not set”) option is shown in the combo box.
Since QGIS 3.20, the optional
text
andicon
arguments allows the text and icon for the empty layer item to be set.See also
New in version 3.0.
- Parameters:
allowEmpty (bool) –
text (str = '') –
icon (QIcon = QIcon()) –
- setExceptedLayerList(self, layerList: Iterable[QgsMapLayer])¶
except a list of layers not to be listed
- Parameters:
layerList (Iterable[QgsMapLayer]) –
- setExcludedProviders(self, providers: Iterable[str])¶
Sets a list of data providers which should be excluded from the combobox.
See also
New in version 3.0.
- Parameters:
providers (Iterable[str]) –
- setFilters(self, filters: QgsMapLayerProxyModel.Filters | QgsMapLayerProxyModel.Filter)¶
setFilters allows filtering according to layer type and/or geometry type.
- Parameters:
filters (Union[QgsMapLayerProxyModel.Filters) –
- setLayer(self, layer: QgsMapLayer)¶
setLayer set the current layer selected in the combo
- Parameters:
layer (QgsMapLayer) –
- setShowCrs(self, showCrs: bool)¶
Sets whether the CRS of layers is also included in the combo box text.
See also
New in version 3.0.
- Parameters:
showCrs (bool) –
- showCrs(self) bool ¶
Returns
True
if the combo box shows the layer’s CRS.See also
New in version 3.0.
- Return type:
bool
- showEvent(self, QShowEvent)¶
- tabletEvent(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- updateMicroFocus(self)¶
- wheelEvent(self, QWheelEvent)¶