Class: QgsStyleModel¶
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.
See also
Added in version 3.4.
Class Hierarchy¶
Base classes¶
Enums
Custom model roles. |
|
alias of |
Methods
Adds an additional icon size to generate for Qt.DecorationRole data. |
|
Adds additional target screen properties to use when generating icons for Qt.DecorationRole data. |
|
Returns the style managed by the model. |
Attributes
- class qgis.core.QgsStyleModel[source]¶
Bases:
QAbstractItemModel
- __init__(style: QgsStyle | None, parent: QObject | None = None)
Constructor for QgsStyleModel, for the specified
style
andparent
object.The
style
object must exist for the lifetime of this model.- Parameters:
style (Optional[QgsStyle])
parent (Optional[QObject] = None)
- class Column¶
Bases:
int
- class CustomRole(*values)¶
Bases:
IntEnum
Custom model roles.
Note
Prior to QGIS 3.36 this was available as QgsStyleModel.Role
Added in version 3.36.
Type
: Style entity type, see QgsStyle.StyleEntityAvailable as
QgsStyleModel.TypeRole
in older QGIS releases.Tag
: String list of tagsAvailable as
QgsStyleModel.TagRole
in older QGIS releases.EntityName
: Entity nameAdded in version 3.26.
SymbolType
: Symbol type (for symbol or legend patch shape entities)Available as
QgsStyleModel.SymbolTypeRole
in older QGIS releases.IsFavorite
: Whether entity is flagged as a favoriteAvailable as
QgsStyleModel.IsFavoriteRole
in older QGIS releases.LayerType
: Layer type (for label settings entities)Available as
QgsStyleModel.LayerTypeRole
in older QGIS releases.CompatibleGeometryTypes
: Compatible layer geometry types (for 3D symbols)Available as
QgsStyleModel.CompatibleGeometryTypesRole
in older QGIS releases.StyleName
: Name of associatedQgsStyle
(QgsStyle.name())Added in version 3.26.
StyleFileName
: File name of associatedQgsStyle
(QgsStyle.fileName())Added in version 3.26.
IsTitle
: True if the index corresponds to a title itemAdded in version 3.26.
Available as
QgsStyleModel.IsTitleRole
in older QGIS releases.
- Name = 0¶
- Role¶
alias of
CustomRole
- Tags = 1¶
- addDesiredIconSize(self, size: QSize)[source]¶
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)[source]¶
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)