Class: QgsStyleModel

class qgis.core.QgsStyleModel

Bases: PyQt5.QtCore.QAbstractItemModel

A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle database.

If you are creating a style model for the default application style (see QgsStyle.defaultStyle()), consider using the shared style model available at QgsApplication.defaultStyleModel() for performance instead.

Added in version 3.4.

QgsStyleModel(style: Optional[QgsStyle], parent: Optional[QObject] = None) Constructor for QgsStyleModel, for the specified style and parent object.

The style object must exist for the lifetime of this model.

Enums

CustomRole

Bases: enum.IntEnum

Role

alias of CustomRole

Methods

addDesiredIconSize

Adds an additional icon size to generate for Qt.DecorationRole data.

addTargetScreenProperties

Adds additional target screen properties to use when generating icons for Qt.DecorationRole data.

beginInsertColumns

beginInsertRows

beginMoveColumns

beginMoveRows

beginRemoveColumns

beginRemoveRows

beginResetModel

changePersistentIndex

changePersistentIndexList

childEvent

columnCount

param parent:

connectNotify

createIndex

customEvent

data

param index:

decodeData

disconnectNotify

encodeData

endInsertColumns

endInsertRows

endMoveColumns

endMoveRows

endRemoveColumns

endRemoveRows

endResetModel

flags

param index:

headerData

param section:

index

param row:

isSignalConnected

parent

param index:

persistentIndexList

receivers

resetInternalData

rowCount

param parent:

sender

senderSignalIndex

setData

param index:

style

Returns the style managed by the model.

timerEvent

Attributes

Name

Tags

class Column

Bases: int

class CustomRole(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: enum.IntEnum

Custom model roles.

Note

Prior to QGIS 3.36 this was available as QgsStyleModel.Role

Added in version 3.36.

  • TypeRole: Style entity type, see QgsStyle.StyleEntity

  • TagRole: String list of tags

  • EntityName: Entity name (since QGIS 3.26)

  • SymbolTypeRole: Symbol type (for symbol or legend patch shape entities)

  • IsFavoriteRole: Whether entity is flagged as a favorite

  • LayerTypeRole: Layer type (for label settings entities)

  • CompatibleGeometryTypesRole: Compatible layer geometry types (for 3D symbols)

  • StyleName: Name of associated QgsStyle (QgsStyle.name()) (since QGIS 3.26)

  • StyleFileName: File name of associated QgsStyle (QgsStyle.fileName()) (since QGIS 3.26)

  • IsTitleRole: True if the index corresponds to a title item (since QGIS 3.26)

baseClass

alias of QgsStyleModel

Name = 0
Role

alias of CustomRole

Tags = 1
addDesiredIconSize(self, size: QSize)

Adds an additional icon size to generate for Qt.DecorationRole data.

This allows style icons to be generated at an icon size which corresponds exactly to the view’s icon size in which this model is used.

Parameters:

size (QSize)

addTargetScreenProperties(self, properties: QgsScreenProperties)

Adds additional target screen properties to use when generating icons for Qt.DecorationRole data.

This allows style icons to be generated at an icon device pixel ratio and DPI which corresponds exactly to the view’s screen properties in which this model is used.

Added in version 3.32.

Parameters:

properties (QgsScreenProperties)

beginInsertColumns(self, parent: QModelIndex, first: int, last: int)
beginInsertRows(self, parent: QModelIndex, first: int, last: int)
beginMoveColumns(self, sourceParent: QModelIndex, sourceFirst: int, sourceLast: int, destinationParent: QModelIndex, destinationColumn: int) bool
beginMoveRows(self, sourceParent: QModelIndex, sourceFirst: int, sourceLast: int, destinationParent: QModelIndex, destinationRow: int) bool
beginRemoveColumns(self, parent: QModelIndex, first: int, last: int)
beginRemoveRows(self, parent: QModelIndex, first: int, last: int)
beginResetModel(self)
changePersistentIndex(self, from_: QModelIndex, to: QModelIndex)
changePersistentIndexList(self, from_: Iterable[QModelIndex], to: Iterable[QModelIndex])
childEvent(self, a0: QChildEvent | None)
columnCount(self, parent: QModelIndex = QModelIndex()) int
Parameters:

parent (QModelIndex = QModelIndex())

Return type:

int

connectNotify(self, signal: QMetaMethod)
createIndex(self, row: int, column: int, object: Any = None) QModelIndex
customEvent(self, a0: QEvent | None)
data(self, index: QModelIndex, role: int) Any
Parameters:
  • index (QModelIndex)

  • role (int)

Return type:

Any

decodeData(self, row: int, column: int, parent: QModelIndex, stream: QDataStream) bool
disconnectNotify(self, signal: QMetaMethod)
encodeData(self, indexes: Iterable[QModelIndex], stream: QDataStream)
endInsertColumns(self)
endInsertRows(self)
endMoveColumns(self)
endMoveRows(self)
endRemoveColumns(self)
endRemoveRows(self)
endResetModel(self)
flags(self, index: QModelIndex) Qt.ItemFlags
Parameters:

index (QModelIndex)

Return type:

Qt.ItemFlags

headerData(self, section: int, orientation: Qt.Orientation, role: int = Qt.DisplayRole) Any
Parameters:
  • section (int)

  • orientation (Qt.Orientation)

  • role (int = Qt.DisplayRole)

Return type:

Any

index(self, row: int, column: int, parent: QModelIndex = QModelIndex()) QModelIndex
Parameters:
  • row (int)

  • column (int)

  • parent (QModelIndex = QModelIndex())

Return type:

QModelIndex

isSignalConnected(self, signal: QMetaMethod) bool
parent(self, index: QModelIndex) QModelIndex
Parameters:

index (QModelIndex)

Return type:

QModelIndex

persistentIndexList(self) List[QModelIndex]
receivers(self, signal: PYQT_SIGNAL) int
resetInternalData(self)
rowCount(self, parent: QModelIndex = QModelIndex()) int
Parameters:

parent (QModelIndex = QModelIndex())

Return type:

int

sender(self) QObject | None
senderSignalIndex(self) int
setData(self, index: QModelIndex, value: Any, role: int = Qt.EditRole) bool
Parameters:
  • index (QModelIndex)

  • value (Any)

  • role (int = Qt.EditRole)

Return type:

bool

style(self) QgsStyle | None

Returns the style managed by the model.

Added in version 3.10.

Return type:

Optional[QgsStyle]

timerEvent(self, a0: QTimerEvent | None)