Class: QgsMapLayerModel¶
-
class
qgis.core.
QgsMapLayerModel
(parent: QObject = None)¶ Bases:
PyQt5.QtCore.QAbstractItemModel
QgsMapLayerModel creates a model to display layers in widgets.
QgsMapLayerModel(layers: Iterable[QgsMapLayer], parent: QObject = None) QgsMapLayerModel creates a model to display a specific list of layers in a widget.
The QgsMapLayerModel class is a model to display layers in widgets.
See also
See also
New in version 2.3: Enums
Methods
Returns the list of additional (non map layer) items included at the end of the model.
Returns true if the model allows the empty layer (“not set”) choice.
checkAll changes the checkstate for all the layers
Returns the icon corresponding to a specified map
layer
.indexFromLayer returns the model index for a given layer
returns if the items can be checked or not
Returns the map layer corresponding to the specified
index
.layersChecked returns the list of layers which are checked (or unchecked)
Sets a list of additional (non map layer) items to include at the end of the model.
Sets whether an optional empty layer (“not set”) option is present in the model.
setItemsCheckable defines if layers should be selectable in the widget
Sets whether the CRS of layers is also included in the model’s display role.
Returns true if the model includes layer’s CRS in the display role.
Signals
Attributes
-
AdditionalRole
= 260¶
-
EmptyRole
= 259¶
-
class
ItemDataRole
¶ Bases:
int
-
baseClass
¶ alias of
QgsMapLayerModel
-
-
LayerIdRole
= 257¶
-
LayerRole
= 258¶
-
addLayers
(self, layers: Iterable[QgsMapLayer])¶
-
additionalItems
(self) → List[str]¶ Returns the list of additional (non map layer) items included at the end of the model.
See also
New in version 3.0.
-
allowEmptyLayer
(self) → bool¶ Returns true if the model allows the empty layer (“not set”) choice.
See also
New in version 3.0.
-
beginInsertColumns
()¶
-
beginInsertRows
()¶
-
beginMoveColumns
()¶
-
beginMoveRows
()¶
-
beginRemoveColumns
()¶
-
beginRemoveRows
()¶
-
beginResetModel
()¶
-
changePersistentIndex
()¶
-
changePersistentIndexList
()¶
-
checkAll
(self, checkState: Qt.CheckState)¶ checkAll changes the checkstate for all the layers
-
childEvent
()¶
-
columnCount
(self, parent: QModelIndex = QModelIndex()) → int¶
-
connectNotify
()¶
-
createIndex
()¶
-
customEvent
()¶
-
data
(self, index: QModelIndex, role: int = Qt.DisplayRole) → Any¶
-
decodeData
()¶
-
disconnectNotify
()¶
-
encodeData
()¶
-
endInsertColumns
()¶
-
endInsertRows
()¶
-
endMoveColumns
()¶
-
endMoveRows
()¶
-
endRemoveColumns
()¶
-
endRemoveRows
()¶
-
endResetModel
()¶
-
flags
(self, index: QModelIndex) → Qt.ItemFlags¶
-
iconForLayer
(layer: QgsMapLayer) → QIcon¶ Returns the icon corresponding to a specified map
layer
.New in version 3.0.
-
index
(self, row: int, column: int, parent: QModelIndex = QModelIndex()) → QModelIndex¶
-
indexFromLayer
(self, layer: QgsMapLayer) → QModelIndex¶ indexFromLayer returns the model index for a given layer
See also
-
isSignalConnected
()¶
-
itemsCheckable
(self) → bool¶ returns if the items can be checked or not
-
layerFromIndex
(self, index: QModelIndex) → QgsMapLayer¶ Returns the map layer corresponding to the specified
index
.See also
New in version 3.0.
-
layersChecked
(self, checkState: Qt.CheckState = Qt.Checked) → List[QgsMapLayer]¶ layersChecked returns the list of layers which are checked (or unchecked)
-
parent
(self, child: QModelIndex) → QModelIndex¶
-
persistentIndexList
()¶
-
receivers
()¶
-
removeLayers
(self, layerIds: Iterable[str])¶
-
resetInternalData
()¶
-
rowCount
(self, parent: QModelIndex = QModelIndex()) → int¶
-
sender
()¶
-
senderSignalIndex
()¶
-
setAdditionalItems
(self, items: Iterable[str])¶ Sets a list of additional (non map layer) items to include at the end of the model. 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.
-
setAllowEmptyLayer
(self, allowEmpty: bool)¶ Sets whether an optional empty layer (“not set”) option is present in the model.
See also
New in version 3.0.
-
setData
(self, index: QModelIndex, value: Any, role: int = Qt.EditRole) → bool¶
-
setItemsCheckable
(self, checkable: bool)¶ setItemsCheckable defines if layers should be selectable in the widget
-
setShowCrs
(self, showCrs: bool)¶ Sets whether the CRS of layers is also included in the model’s display role.
See also
New in version 3.0.
-
showCrs
(self) → bool¶ Returns true if the model includes layer’s CRS in the display role.
See also
New in version 3.0.
-
timerEvent
()¶
-