Subgroup: Map

Class: QgsMapLayerModel

class qgis.core.QgsMapLayerModel

Bases: PyQt5.QtCore.QAbstractItemModel

The QgsMapLayerModel class is a model to display layers in widgets.

See also

QgsFieldModel

New in version 2.3: Methods

addLayers
additionalItems Return the list of additional (non map layer) items included at the end of the model.
allowEmptyLayer Returns true if the model allows the empty layer (“not set”) choice.
beginInsertColumns
beginInsertRows
beginMoveColumns
beginMoveRows
beginRemoveColumns
beginRemoveRows
beginResetModel
blockSignals
buddy
canDropMimeData
canFetchMore
changePersistentIndex
changePersistentIndexList
checkAll checkAll changes the checkstate for all the layers
childEvent
children
columnCount
connectNotify
createIndex
customEvent
data
decodeData
deleteLater
disconnect
disconnectNotify
dropMimeData
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
encodeData
endInsertColumns
endInsertRows
endMoveColumns
endMoveRows
endRemoveColumns
endRemoveRows
endResetModel
event
eventFilter
fetchMore
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]
flags
hasChildren
hasIndex
headerData
iconForLayer Returns the icon corresponding to a specified map layer.
index
indexFromLayer indexFromLayer returns the model index for a given layer
inherits
insertColumn
insertColumns
insertRow
insertRows
installEventFilter
isSignalConnected
isWidgetType
isWindowType
itemData
itemsCheckable returns if the items can be checked or not
killTimer
layerFromIndex Returns the map layer corresponding to the specified index.
layersChecked layersChecked returns the list of layers which are checked (or unchecked)
match
metaObject
mimeData
mimeTypes
moveColumn
moveColumns
moveRow
moveRows
moveToThread
objectName
parent
persistentIndexList
property
pyqtConfigure Each keyword argument is either the name of a Qt property or a Qt signal.
receivers
removeColumn
removeColumns
removeEventFilter
removeLayers
removeRow
removeRows
resetInternalData
revert
roleNames
rowCount
sender
senderSignalIndex
setAdditionalItems Sets a list of additional (non map layer) items to include at the end of the model.
setAllowEmptyLayer Sets whether an optional empty layer (“not set”) option is present in the model.
setData
setHeaderData
setItemData
setItemsCheckable setItemsCheckable defines if layers should be selectable in the widget
setObjectName
setParent
setProperty
setShowCrs Sets whether the CRS of layers is also included in the model’s display role.
showCrs Returns true if the model includes layer’s CRS in the display role.
sibling
signalsBlocked
sort
span
startTimer
submit
supportedDragActions
supportedDropActions
thread
timerEvent
tr

Attributes

AdditionalRole
EmptyRole
HorizontalSortHint
LayerIdRole
LayerRole
NoLayoutChangeHint
VerticalSortHint
columnsAboutToBeInserted columnsAboutToBeInserted(self, QModelIndex, int, int) [signal]
columnsAboutToBeMoved columnsAboutToBeMoved(self, QModelIndex, int, int, QModelIndex, int) [signal]
columnsAboutToBeRemoved columnsAboutToBeRemoved(self, QModelIndex, int, int) [signal]
columnsInserted columnsInserted(self, QModelIndex, int, int) [signal]
columnsMoved columnsMoved(self, QModelIndex, int, int, QModelIndex, int) [signal]
columnsRemoved columnsRemoved(self, QModelIndex, int, int) [signal]
dataChanged dataChanged(self, QModelIndex, QModelIndex, Iterable[int] = []) [signal]
destroyed destroyed(self, QObject = None) [signal]
layoutAboutToBeChanged layoutAboutToBeChanged(self, object = QList<QPersistentModelIndex>(), QAbstractItemModel.LayoutChangeHint = QAbstractItemModel.NoLayoutChangeHint) [signal]
layoutChanged layoutChanged(self, Iterable[QPersistentModelIndex] = [], QAbstractItemModel.LayoutChangeHint = QAbstractItemModel.NoLayoutChangeHint) [signal]
modelAboutToBeReset modelAboutToBeReset(self) [signal]
modelReset modelReset(self) [signal]
objectNameChanged objectNameChanged(self, str) [signal]
rowsAboutToBeInserted rowsAboutToBeInserted(self, QModelIndex, int, int) [signal]
rowsAboutToBeMoved rowsAboutToBeMoved(self, QModelIndex, int, int, QModelIndex, int) [signal]
rowsAboutToBeRemoved rowsAboutToBeRemoved(self, QModelIndex, int, int) [signal]
rowsInserted rowsInserted(self, QModelIndex, int, int) [signal]
rowsMoved rowsMoved(self, QModelIndex, int, int, QModelIndex, int) [signal]
rowsRemoved rowsRemoved(self, QModelIndex, int, int) [signal]
staticMetaObject
AdditionalRole = 260
EmptyRole = 259
class ItemDataRole

Bases: int

LayerIdRole = 257
LayerRole = 258
addLayers(self, layers: Iterable[QgsMapLayer])
additionalItems(self) → List[str]

Return the list of additional (non map layer) items included at the end of the model.

New in version 3.0.

allowEmptyLayer(self) → bool

Returns true if the model allows the empty layer (“not set”) choice.

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

layerFromIndex()

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.

New in version 3.0.

See also

indexFromLayer()

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.

New in version 3.0.

setAllowEmptyLayer(self, allowEmpty: bool)

Sets whether an optional empty layer (“not set”) option is present in the model.

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

showCrs()

New in version 3.0.

showCrs(self) → bool

Returns true if the model includes layer’s CRS in the display role.

See also

setShowCrs()

New in version 3.0.

timerEvent()