Class: QgsStyle¶
A database of saved style entities, including symbols, color ramps, text formats and others.
Class Hierarchy¶
Base classes¶
- class qgis.core.QgsStyle[source]¶
Bases:
QObject- __init__(parent: QObject | None = None)
Constructor for QgsStyle, with the specified
parentobject.- Parameters:
parent (Optional[QObject] = None)
- class ColorRampTableColumn(*values)¶
Bases:
IntEnumColumns available in the color ramp table.
Added in version 3.40..
Id: Color ramp IDName: Color ramp nameXML: Color ramp definition (as XML)FavoriteId: Color ramp is favorite flag
- ColorrampFavoriteId = 3¶
- ColorrampId = 0¶
- ColorrampName = 1¶
- ColorrampXML = 2¶
- FavoriteId = 3¶
- Id = 0¶
- Name = 1¶
- XML = 2¶
- ColorrampEntity = 2¶
- LabelSettingsEntity = 5¶
- class LabelSettingsTableColumn(*values)¶
Bases:
IntEnumColumns available in the label settings table.
Added in version 3.40..
Id: Label settings IDName: Label settings nameXML: Label settings definition (as XML)FavoriteId: Label settings is favorite flag
- FavoriteId = 3¶
- Id = 0¶
- LabelSettingsFavoriteId = 3¶
- LabelSettingsId = 0¶
- LabelSettingsName = 1¶
- LabelSettingsXML = 2¶
- Name = 1¶
- XML = 2¶
- LegendPatchShapeEntity = 6¶
- class SmartGroupTableColumn(*values)¶
Bases:
IntEnumColumns available in the smart group table.
Added in version 3.40..
Id: Smart group IDName: Smart group nameXML: Smart group definition (as XML)
- Id = 0¶
- Name = 1¶
- SmartgroupId = 0¶
- SmartgroupName = 1¶
- SmartgroupXML = 2¶
- XML = 2¶
- SmartgroupEntity = 3¶
- class StyleEntity¶
Bases:
int
- Symbol3DEntity = 7¶
- SymbolEntity = 0¶
- class SymbolTableColumn(*values)¶
Bases:
IntEnumColumns available in the Symbols table.
Added in version 3.40..
Id: Symbol IDName: Symbol NameXML: Symbol definition (as XML)FavoriteId: Symbol is favorite flag
- FavoriteId = 3¶
- Id = 0¶
- Name = 1¶
- SymbolFavoriteId = 3¶
- SymbolId = 0¶
- SymbolName = 1¶
- SymbolXML = 2¶
- XML = 2¶
- TagEntity = 1¶
- class TagTableColumn(*values)¶
Bases:
IntEnumColumns available in the Tags table.
Added in version 3.40..
Id: Tag IDName: Tag name
- Id = 0¶
- Name = 1¶
- TagId = 0¶
- TagName = 1¶
- class TagmapTableColumn(*values)¶
Bases:
IntEnumColumns available in the tag to symbol table.
Added in version 3.40..
TagId: Tag IDSymbolId: Symbol ID
- SymbolId = 1¶
- TagId = 0¶
- TagmapSymbolId = 1¶
- TagmapTagId = 0¶
- class TextFormatContext(*values)¶
Bases:
IntEnumText format context.
Added in version 3.20.
Labeling: Text format used in labeling
- Labeling = 0¶
- TextFormatEntity = 4¶
- class TextFormatTableColumn(*values)¶
Bases:
IntEnumColumns available in the text format table.
Added in version 3.40..
Id: Text format IDName: Text format nameXML: Text format definition (as XML)FavoriteId: Text format is favorite flag
- FavoriteId = 3¶
- Id = 0¶
- Name = 1¶
- TextFormatFavoriteId = 3¶
- TextFormatId = 0¶
- TextFormatName = 1¶
- TextFormatXML = 2¶
- XML = 2¶
- signal aboutToBeDestroyed[source]¶
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.
- addColorRamp(self, name: str | None, colorRamp: QgsColorRamp | None, update: bool = False) bool[source]¶
Adds a color ramp to the style. Calling this method takes the ramp’s ownership.
Note
Adding a color ramp with the name of existing one replaces it.
- Parameters:
name (Optional[str]) – is the name of the color ramp being added or updated
colorRamp (Optional[QgsColorRamp]) – is the color ramp. Ownership is transferred.
update (bool = False) – set to
Truewhen the style database has to be updated, by default it isFalse
- Return type:
bool
- Returns:
success status of the operation
- addEntity(self, name: str | None, entity: QgsStyleEntityInterface | None, update: bool = False) bool[source]¶
Adds an
entityto the style, with the specifiedname. Ownership is not transferred.If
updateisTruethen the style database is updated automatically as a result.Returns
Trueif the add operation was successful.Note
Adding an entity with the name of existing one replaces the existing one automatically.
Added in version 3.10.
- Parameters:
name (Optional[str])
entity (Optional[QgsStyleEntityInterface])
update (bool = False)
- Return type:
bool
- addFavorite(self, type: QgsStyle.StyleEntity, name: str | None) bool[source]¶
Adds the specified symbol to favorites
- Parameters:
type (QgsStyle.StyleEntity) – is either SymbolEntity of ColorrampEntity
name (Optional[str]) – is the name of the symbol or coloramp whose is to be added to favorites
- Return type:
bool
- Returns:
returns the success state as bool
- addLabelSettings(self, name: str | None, settings: QgsPalLayerSettings, update: bool = False) bool[source]¶
Adds label
settingswith the specifiednameto the style.If
updateis set toTrue, the style database will be automatically updated with the new text format.Returns
Trueif the operation was successful.Note
Adding label settings with the name of existing ones replaces them.
Added in version 3.10.
- Parameters:
name (Optional[str])
settings (QgsPalLayerSettings)
update (bool = False)
- Return type:
bool
- addLegendPatchShape(self, name: str | None, shape: QgsLegendPatchShape, update: bool = False) bool[source]¶
Adds a legend patch
shapewith the specifiednameto the style.If
updateis set toTrue, the style database will be automatically updated with the new legend patch shape.Returns
Trueif the operation was successful.Note
Adding legend patch shapes with the name of existing ones replaces them.
Added in version 3.14.
- Parameters:
name (Optional[str])
shape (QgsLegendPatchShape)
update (bool = False)
- Return type:
bool
- addSmartgroup(self, name: str | None, op: str | None, matchTag: Iterable[str | None], noMatchTag: Iterable[str | None], matchName: Iterable[str | None], noMatchName: Iterable[str | None]) int[source]¶
Adds a new smartgroup to the database and returns the id.
- Parameters:
name (Optional[str]) – is the name of the new Smart Group to be added
op (Optional[str]) – is the operator between the conditions; AND/OR as string
matchTag (Iterable[Optional[str]]) – list of strings to match within tags
noMatchTag (Iterable[Optional[str]]) – list of strings to exclude matches from tags
matchName (Iterable[Optional[str]]) – list of string to match within names
noMatchName (Iterable[Optional[str]]) – list of strings to exclude matches from names
Added in version 3.4.
- Return type:
int
- addSymbol(self, name: str | None, symbol: QgsSymbol | None, update: bool = False) bool[source]¶
Adds a symbol to style and takes symbol’s ownership
Note
Adding a symbol with the name of existing one replaces it.
- Parameters:
name (Optional[str]) – is the name of the symbol being added or updated
symbol (Optional[QgsSymbol]) – is the Vector symbol
update (bool = False) – set to
Truewhen the style database has to be updated, by default it isFalse
- Return type:
bool
- Returns:
success status of the operation
- addSymbol3D(self, name: str | None, symbol: QgsAbstract3DSymbol | None, update: bool = False) bool[source]¶
Adds a 3d
symbolwith the specifiednameto the style. Ownership ofsymbolis transferred.If
updateis set toTrue, the style database will be automatically updated with the new legend patch shape.Returns
Trueif the operation was successful.Note
Adding 3d symbols with the name of existing ones replaces them.
Added in version 3.16.
- Parameters:
name (Optional[str])
symbol (Optional[QgsAbstract3DSymbol])
update (bool = False)
- Return type:
bool
- addTag(self, tagName: str | None) int[source]¶
Adds a new tag and returns the tag’s id
- Parameters:
tagName (Optional[str]) – the name of the new tag to be created
- Return type:
int
- Returns:
returns an int, which is the database id of the new tag created, 0 if the tag couldn’t be created
- addTextFormat(self, name: str | None, format: QgsTextFormat, update: bool = False) bool[source]¶
Adds a text
formatwith the specifiednameto the style.If
updateis set toTrue, the style database will be automatically updated with the new text format.Returns
Trueif the operation was successful.Note
Adding a text format with the name of existing one replaces it.
Added in version 3.10.
- Parameters:
name (Optional[str])
format (QgsTextFormat)
update (bool = False)
- Return type:
bool
- allNames(self, type: QgsStyle.StyleEntity) List[str][source]¶
Returns a list of the names of all existing entities of the specified
type.Added in version 3.10.
- Parameters:
type (QgsStyle.StyleEntity)
- Return type:
List[str]
- colorRamp(self, name: str | None) QgsColorRamp | None[source]¶
Returns a new copy of the specified color ramp. The caller takes responsibility for deleting the returned object.
- Parameters:
name (Optional[str])
- Return type:
Optional[QgsColorRamp]
- colorRampNames(self) List[str][source]¶
Returns a list of names of color ramps
- Return type:
List[str]
- colorRampRef(self, name: str | None) QgsColorRamp | None[source]¶
Returns a const pointer to a symbol (doesn’t create new instance)
- Parameters:
name (Optional[str])
- Return type:
Optional[QgsColorRamp]
- colorrampId(self, name: str | None) int[source]¶
Returns the id in the style database for the given colorramp name returns 0 if not found
- Parameters:
name (Optional[str])
- Return type:
int
- createDatabase(self, filename: str | None) bool[source]¶
Creates an on-disk database
This function creates a new on-disk permanent style database.
- Return type:
bool
- Returns:
returns the success state of the database creation
See also
- Parameters:
filename (Optional[str])
- createMemoryDatabase(self) bool[source]¶
Creates a temporary memory database
This function is used to create a temporary style database in case a permanent on-disk database is not needed.
- Return type:
bool
- Returns:
returns the success state of the temporary memory database creation
See also
- createTables(self)[source]¶
Creates tables structure for new database
This function is used to create the tables structure in a newly-created database.
See also
See also
- defaultPatch(self, type: Qgis.SymbolType, size: QSizeF) QgsLegendPatchShape[source]¶
Returns the default legend patch shape for the given symbol
type.See also
Added in version 3.14.
- Parameters:
type (Qgis.SymbolType)
size (QSizeF)
- Return type:
- defaultPatchAsQPolygonF(self, type: Qgis.SymbolType, size: QSizeF) Any¶
Returns the default patch geometry for the given symbol
typeandsizeas a set of QPolygonF objects (parts and rings).See also
Added in version 3.14.
- Parameters:
type (Qgis.SymbolType)
size (QSizeF)
- Return type:
- static defaultStyle(initialize: bool = True) QgsStyle | None[source]¶
Returns the default application-wide style.
Since QGIS 3.36, the
initializeargument can be set toFalseto temporarily defer the actual loading of the style’s objects until they are first requested. This lazy-initialization can substantially improve application startup times, especially for standalone applications which do not utilize styles.- Parameters:
initialize (bool = True)
- Return type:
Optional[QgsStyle]
- defaultTextFormat(self, context: QgsStyle.TextFormatContext = QgsStyle.TextFormatContext.Labeling) QgsTextFormat[source]¶
Returns the default text format to use for new text based objects in the specified
context.Added in version 3.20.
- Parameters:
context (QgsStyle.TextFormatContext = QgsStyle.TextFormatContext.Labeling)
- Return type:
- static defaultTextFormatForProject(project: QgsProject | None, context: QgsStyle.TextFormatContext = QgsStyle.TextFormatContext.Labeling) QgsTextFormat[source]¶
Returns the default text format to use for new text based objects for the specified
project, in the specifiedcontext.Added in version 3.26.
- Parameters:
project (Optional[QgsProject])
context (QgsStyle.TextFormatContext = QgsStyle.TextFormatContext.Labeling)
- Return type:
- detagSymbol(self, type: QgsStyle.StyleEntity, symbol: str | None, tags: Iterable[str | None]) bool[source]¶
Detags the symbol with the given list
Removes the given tags for the specified symbol or colorramp
- Parameters:
type (QgsStyle.StyleEntity) – is either SymbolEntity or ColorrampEntity
symbol (Optional[str]) – is the name of the symbol or colorramp
tags (Iterable[Optional[str]]) – is the list of tags that are to be removed as QStringList
- Returns:
returns the success state of the operation
detagSymbol(self, type: QgsStyle.StyleEntity, symbol: Optional[str]) -> bool Clears the symbol from all attached tags
Removes all tags for the specified symbol or colorramp
- Parameters:
type – is either SymbolEntity or ColorrampEntity
symbol – is the name of the symbol or colorramp
- Return type:
bool
- Returns:
returns the success state of the operation
- signal entityAdded[source]¶
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.
- signal entityChanged[source]¶
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.
- entityId(self, type: QgsStyle.StyleEntity, name: str | None) int[source]¶
Returns the id in the style database for the given
nameof the specified entitytype. Returns 0 if not found.- Parameters:
type (QgsStyle.StyleEntity)
name (Optional[str])
- Return type:
int
- signal entityRemoved[source]¶
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.
- signal entityRenamed[source]¶
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.
- signal entityTagsChanged[source]¶
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.
- errorString(self) str[source]¶
Returns the last error from a
load()operation.See also
- Return type:
str
- exportXml(self, filename: str | None) bool[source]¶
Exports the style as a XML file
- Parameters:
filename (Optional[str])
- Return type:
bool
- signal favoritedChanged[source]¶
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.
- fileName(self) str[source]¶
Returns the current file name of the style database.
The filename will always represent the actual source of the style - e.g. the .db file for styles associated with a database, or the original source .xml file for styles directly loaded from a .xml export.
See also
- Return type:
str
- findSymbols(self, type: QgsStyle.StyleEntity, qword: str | None) List[str][source]¶
Returns the names of the symbols which have a matching ‘substring’ in its definition
- Parameters:
type (QgsStyle.StyleEntity) – is either SymbolEntity or ColorrampEntity
qword (Optional[str]) – is the query string to search the symbols or colorramps.
- Return type:
List[str]
- Returns:
A QStringList of the matched symbols or colorramps
- signal groupsModified[source]¶
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.
- importXml(self, filename: str | None) bool[source]¶
Imports the symbols and colorramps into the default style database from the given XML file
- Parameters:
filename (Optional[str])
- Return type:
bool
- signal initialized[source]¶
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.
- isFavorite(self, type: QgsStyle.StyleEntity, name: str | None) bool[source]¶
Returns
Trueif the symbol with matchingtypeandnameis marked as a favorite.Added in version 3.10.
- Parameters:
type (QgsStyle.StyleEntity)
name (Optional[str])
- Return type:
bool
- isInitialized(self) bool[source]¶
Returns
Trueif the style is initialized and ready for use.Most instances of
QgsStylewill already be initialized. However, if the style is theQgsStyle.defaultStyle()object it may have been created using lazy initialization and will returnFalseuntil it isinitialized().Added in version 3.36.
- Return type:
bool
- isReadOnly(self) bool[source]¶
Returns
Trueif the style is considered a read-only library.Note
This flag is used to control GUI operations, and does not prevent calling functions which mutate the style directly via the API.
See also
Added in version 3.26.
- Return type:
bool
- static isXmlStyleFile(path: str | None) bool[source]¶
Tests if the file at
pathis a QGIS style XML file.This method samples only the first line in the file, so is safe to call on large xml files.
Added in version 3.6.
- Parameters:
path (Optional[str])
- Return type:
bool
- labelSettings(self, name: str | None) QgsPalLayerSettings[source]¶
Returns the label settings with the specified
name.Added in version 3.10.
- Parameters:
name (Optional[str])
- Return type:
- signal labelSettingsAdded[source]¶
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.
- signal labelSettingsChanged[source]¶
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.
- labelSettingsCount(self) int[source]¶
Returns count of label settings in the style.
Added in version 3.10.
- Return type:
int
- labelSettingsId(self, name: str | None) int[source]¶
Returns the ID in the style database for the given label settings by
name. Returns 0 if the label settings were not found.Added in version 3.10.
- Parameters:
name (Optional[str])
- Return type:
int
- labelSettingsLayerType(self, name: str | None) Qgis.GeometryType[source]¶
Returns the layer geometry type corresponding to the label settings with the specified
name, orQgis.GeometryType.Unknown if matching label settings are not present.Added in version 3.10.
- Parameters:
name (Optional[str])
- Return type:
- labelSettingsNames(self) List[str][source]¶
Returns a list of names of label settings in the style.
Added in version 3.10.
- Return type:
List[str]
- signal labelSettingsRemoved[source]¶
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.
- signal labelSettingsRenamed[source]¶
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.
- legendPatchShape(self, name: str | None) QgsLegendPatchShape[source]¶
Returns the legend patch shape with the specified
name.Added in version 3.14.
- Parameters:
name (Optional[str])
- Return type:
- legendPatchShapeNames(self) List[str][source]¶
Returns a list of names of legend patch shapes in the style.
Added in version 3.14.
- Return type:
List[str]
- legendPatchShapeSymbolType(self, name: str | None) Qgis.SymbolType[source]¶
Returns the symbol type corresponding to the legend patch shape with the specified
name, orQgsSymbol.Hybrid if a matching legend patch shape is not present.Added in version 3.14.
- Parameters:
name (Optional[str])
- Return type:
- legendPatchShapesCount(self) int[source]¶
Returns count of legend patch shapes in the style.
Added in version 3.14.
- Return type:
int
- load(self, filename: str | None) bool[source]¶
Loads a file into the style
This function will load an on-disk database and populate styles.
- Parameters:
filename (Optional[str]) – location of the database to load styles from
- Return type:
bool
- Returns:
Trueif the database was successfully loaded. IfFalseis returned then a detailed error message can be retrieved viaerrorString().
See also
- name(self) str[source]¶
Returns the name of the style.
See also
Added in version 3.26.
- Return type:
str
- previewSymbolForPatchShape(self, shape: QgsLegendPatchShape) QgsSymbol | None[source]¶
Returns a symbol to use for rendering preview icons for a patch
shape.Ownership of the symbol is not transferred.
Added in version 3.14.
- Parameters:
shape (QgsLegendPatchShape)
- Return type:
Optional[QgsSymbol]
- signal rampAdded[source]¶
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.
- signal rampChanged[source]¶
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.
- signal rampRemoved[source]¶
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.
- signal rampRenamed[source]¶
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.
- signal rebuildIconPreviews[source]¶
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.
- remove(self, type: QgsStyle.StyleEntity, id: int) bool[source]¶
Removes the specified entity from the database.
- Parameters:
type (QgsStyle.StyleEntity) – is any of the style entities. Refer enum StyleEntity.
id (int) – is the database id of the entity to be removed
See also
- Return type:
bool
- removeColorRamp(self, name: str | None) bool[source]¶
Removes color ramp from style (and delete it)
- Parameters:
name (Optional[str])
- Return type:
bool
- removeEntityByName(self, type: QgsStyle.StyleEntity, name: str | None) bool[source]¶
Removes the entry of the specified
typewith matchingnamefrom the database.See also
Added in version 3.14.
- Parameters:
type (QgsStyle.StyleEntity)
name (Optional[str])
- Return type:
bool
- removeFavorite(self, type: QgsStyle.StyleEntity, name: str | None) bool[source]¶
Removes the specified symbol from favorites
- Parameters:
type (QgsStyle.StyleEntity) – is either SymbolEntity of ColorrampEntity
name (Optional[str]) – is the name of the symbol or coloramp whose is to be removed from favorites
- Return type:
bool
- Returns:
returns the success state as bool
- removeLabelSettings(self, name: str | None) bool[source]¶
Removes label settings from the style.
Added in version 3.10.
- Parameters:
name (Optional[str])
- Return type:
bool
- removeSymbol(self, name: str | None) bool[source]¶
Removes symbol from style (and delete it)
- Parameters:
name (Optional[str])
- Return type:
bool
- removeTextFormat(self, name: str | None) bool[source]¶
Removes a text format from the style.
Added in version 3.10.
- Parameters:
name (Optional[str])
- Return type:
bool
- rename(self, type: QgsStyle.StyleEntity, id: int, newName: str | None) bool[source]¶
Renames the given entity with the specified id
- Parameters:
type (QgsStyle.StyleEntity) – is any of the style entities. Refer enum StyleEntity.
id (int) – is the database id of the entity which is to be renamed
newName (Optional[str]) – is the new name of the entity
- Return type:
bool
- renameColorRamp(self, oldName: str | None, newName: str | None) bool[source]¶
Changes ramp’s name
- Parameters:
oldName (Optional[str])
newName (Optional[str])
- Return type:
bool
- renameEntity(self, type: QgsStyle.StyleEntity, oldName: str | None, newName: str | None) bool[source]¶
Renames an entity of the specified
typefromoldNametonewName.Returns
Trueif the entity was successfully renamed.Added in version 3.14.
- Parameters:
type (QgsStyle.StyleEntity)
oldName (Optional[str])
newName (Optional[str])
- Return type:
bool
- renameLabelSettings(self, oldName: str | None, newName: str | None) bool[source]¶
Changes a label setting’s name.
Added in version 3.10.
- Parameters:
oldName (Optional[str])
newName (Optional[str])
- Return type:
bool
- renameLegendPatchShape(self, oldName: str | None, newName: str | None) bool[source]¶
Changes a legend patch shape’s name.
Added in version 3.14.
- Parameters:
oldName (Optional[str])
newName (Optional[str])
- Return type:
bool
- renameSymbol(self, oldName: str | None, newName: str | None) bool[source]¶
Renames a symbol from
oldNametonewName.Returns
Trueif symbol was successfully renamed.- Parameters:
oldName (Optional[str])
newName (Optional[str])
- Return type:
bool
- renameSymbol3D(self, oldName: str | None, newName: str | None) bool[source]¶
Changes a 3d symbol’s name.
Added in version 3.16.
- Parameters:
oldName (Optional[str])
newName (Optional[str])
- Return type:
bool
- renameTextFormat(self, oldName: str | None, newName: str | None) bool[source]¶
Changes a text format’s name.
Added in version 3.10.
- Parameters:
oldName (Optional[str])
newName (Optional[str])
- Return type:
bool
- save(self, filename: str | None = '') bool[source]¶
Saves style into a file.
The current
fileName()will be used if no explicitfilenameis specified.- Return type:
bool
- Returns:
Trueif the style was successfully saved. IfFalseis returned then a detailed error message can be retrieved viaerrorString().
See also
See also
See also
Deprecated since version 3.40: This function has no effect.
- Parameters:
filename (Optional[str] = '')
- saveColorRamp(self, name: str | None, ramp: QgsColorRamp | None, favorite: bool, tags: Iterable[str | None]) bool[source]¶
Adds the colorramp to the database.
- Parameters:
name (Optional[str]) – is the name of the colorramp as string
ramp (Optional[QgsColorRamp]) – is the pointer to the new
QgsColorRampbeing savedfavorite (bool) – is a boolean value to specify whether the colorramp should be added to favorites
tags (Iterable[Optional[str]]) – is a list of tags that are associated with the color ramp as a QStringList.
- Return type:
bool
- Returns:
returns the success state of the save operation
- saveLabelSettings(self, name: str | None, settings: QgsPalLayerSettings, favorite: bool, tags: Iterable[str | None]) bool[source]¶
Adds label
settingsto the database.- Parameters:
name (Optional[str]) – is the name of the label settings
settings (QgsPalLayerSettings) – label settings to save
favorite (bool) – is a boolean value to specify whether the label settings should be added to favorites
tags (Iterable[Optional[str]]) – is a list of tags that are associated with the label settings
- Return type:
bool
- Returns:
returns the success state of the save operation
- saveLegendPatchShape(self, name: str | None, shape: QgsLegendPatchShape, favorite: bool, tags: Iterable[str | None]) bool[source]¶
Adds a legend patch
shapeto the database.- Parameters:
name (Optional[str]) – is the name of the legend patch shape
shape (QgsLegendPatchShape) – legend patch shape to save
favorite (bool) – is a boolean value to specify whether the legend patch shape should be added to favorites
tags (Iterable[Optional[str]]) – is a list of tags that are associated with the legend patch shape
- Return type:
bool
- Returns:
returns the success state of the save operation
Added in version 3.14.
- saveSymbol(self, name: str | None, symbol: QgsSymbol | None, favorite: bool, tags: Iterable[str | None]) bool[source]¶
Adds the symbol to the database with tags.
- Parameters:
name (Optional[str]) – is the name of the symbol as string
symbol (Optional[QgsSymbol]) – is the pointer to the new
QgsSymbolbeing savedfavorite (bool) – is a boolean value to specify whether the symbol should be added to favorites
tags (Iterable[Optional[str]]) – is a list of tags that are associated with the symbol as a QStringList.
- Return type:
bool
- Returns:
returns the success state of the save operation
- saveSymbol3D(self, name: str | None, symbol: QgsAbstract3DSymbol | None, favorite: bool, tags: Iterable[str | None]) bool[source]¶
Adds a 3d
symbolto the database.- Parameters:
name (Optional[str]) – is the name of the 3d symbol
symbol (Optional[QgsAbstract3DSymbol]) – 3d symbol to save. Ownership is transferred.
favorite (bool) – is a boolean value to specify whether the 3d symbol should be added to favorites
tags (Iterable[Optional[str]]) – is a list of tags that are associated with the 3d symbol
- Return type:
bool
- Returns:
returns the success state of the save operation
Added in version 3.16.
- saveTextFormat(self, name: str | None, format: QgsTextFormat, favorite: bool, tags: Iterable[str | None]) bool[source]¶
Adds a text
formatto the database.- Parameters:
name (Optional[str]) – is the name of the text format
format (QgsTextFormat) – text format to save
favorite (bool) – is a boolean value to specify whether the text format should be added to favorites
tags (Iterable[Optional[str]]) – is a list of tags that are associated with the text format
- Return type:
bool
- Returns:
returns the success state of the save operation
- setFileName(self, filename: str | None)[source]¶
Sets the current file name of the style database.
The filename should always represent the actual source of the style - e.g. the .db file for styles associated with a database, or the original source .xml file for styles directly loaded from a .xml export.
Calling
load()automatically sets the filename to the .db file path.Added in version 3.26.
- Parameters:
filename (Optional[str])
- setName(self, name: str | None)[source]¶
Sets the
nameof the style.See also
Added in version 3.26.
- Parameters:
name (Optional[str])
- setReadOnly(self, readOnly: bool)[source]¶
Sets whether the style is considered a read-only library.
Note
This flag is used to control GUI operations, and does not prevent calling functions which mutate the style directly via the API.
See also
Added in version 3.26.
- Parameters:
readOnly (bool)
- smartgroup(self, id: int) Dict[str, List[str]][source]¶
Returns the
QgsSmartConditionMapfor the given id- Parameters:
id (int)
- Return type:
Dict[str, List[str]]
- smartgroupId(self, smartgroup: str | None) int[source]¶
Returns the database id for the given smartgroup name
- Parameters:
smartgroup (Optional[str])
- Return type:
int
- smartgroupOperator(self, id: int) str[source]¶
Returns the operator for the smartgroup.
- Parameters:
id (int)
- Return type:
str
- smartgroupsListMap(self) Dict[int, str][source]¶
Returns the smart groups map with id as key and name as value
- Return type:
Dict[int, str]
- symbol(self, name: str | None) QgsSymbol | None[source]¶
Returns a NEW copy of symbol
- Parameters:
name (Optional[str])
- Return type:
Optional[QgsSymbol]
- symbol3D(self, name: str | None) QgsAbstract3DSymbol | None[source]¶
Returns a new copy of the 3D symbol with the specified
name.Added in version 3.16.
- Parameters:
name (Optional[str])
- Return type:
Optional[QgsAbstract3DSymbol]
- symbol3DCompatibleGeometryTypes(self, name: str | None) List[Qgis.GeometryType]¶
Returns the list of the vector layer geometry types which are compatible with the 3D symbol with the specified
name, or an empty list if a matching 3d symbol is not present.Added in version 3.16.
- Parameters:
name (Optional[str])
- Return type:
- symbol3DCount(self) int[source]¶
Returns count of 3D symbols in the style.
Added in version 3.16.
- Return type:
int
- symbol3DNames(self) List[str][source]¶
Returns a list of names of 3d symbols in the style.
Added in version 3.16.
- Return type:
List[str]
- signal symbolChanged[source]¶
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.
- symbolHasTag(self, type: QgsStyle.StyleEntity, symbol: str | None, tag: str | None) bool[source]¶
Returns whether a given tag is associated with the symbol
- Parameters:
type (QgsStyle.StyleEntity) – is either SymbolEntity or ColorrampEntity
symbol (Optional[str]) – is the name of the symbol or color ramp
tag (Optional[str]) – the name of the tag to look for
- Return type:
bool
- Returns:
A boolean value identicating whether a tag was found attached to the symbol
- symbolId(self, name: str | None) int[source]¶
Returns the id in the style database for the given symbol name returns 0 if not found
- Parameters:
name (Optional[str])
- Return type:
int
- symbolRef(self, name: str | None) QgsSymbol | None[source]¶
Returns a const pointer to a symbol (doesn’t create new instance)
- Parameters:
name (Optional[str])
- Return type:
Optional[QgsSymbol]
- signal symbolRemoved[source]¶
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.
- signal symbolRenamed[source]¶
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.
- signal symbolSaved[source]¶
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.
- symbolsOfFavorite(self, type: QgsStyle.StyleEntity) List[str][source]¶
Returns the symbol names which are flagged as favorite
- Parameters:
type (QgsStyle.StyleEntity) – is either SymbolEntity or ColorampEntity
- Return type:
List[str]
- Returns:
A QStringList of the symbol or colorramp names flagged as favorite
- symbolsOfSmartgroup(self, type: QgsStyle.StyleEntity, id: int) List[str][source]¶
Returns the symbols for the smartgroup
- Parameters:
type (QgsStyle.StyleEntity)
id (int)
- Return type:
List[str]
- symbolsWithTag(self, type: QgsStyle.StyleEntity, tagid: int) List[str][source]¶
Returns the symbol names with which have the given tag
- Parameters:
type (QgsStyle.StyleEntity) – is either SymbolEntity or ColorampEntity
tagid (int) – is id of the tag which has been applied over the symbol as int
- Return type:
List[str]
- Returns:
A QStringList of the symbol or colorramp names for the given tag id
- tag(self, id: int) str[source]¶
Returns the tag name for the given id
- Parameters:
id (int)
- Return type:
str
- tagId(self, tag: str | None) int[source]¶
Returns the database id for the given tag name
- Parameters:
tag (Optional[str])
- Return type:
int
- tagSymbol(self, type: QgsStyle.StyleEntity, symbol: str | None, tags: Iterable[str | None]) bool[source]¶
Tags the symbol with the tags in the list
Applies the given tags to the given symbol or colorramp
- Parameters:
type (QgsStyle.StyleEntity) – is either SymbolEntity or ColorrampEntity
symbol (Optional[str]) – is the name of the symbol or colorramp as string
tags (Iterable[Optional[str]]) – is the list of the tags that are to be applied as QStringList
- Return type:
bool
- Returns:
returns the success state of the operation
- tags(self) List[str][source]¶
Returns a list of all tags in the style database
See also
- Return type:
List[str]
- tagsOfSymbol(self, type: QgsStyle.StyleEntity, symbol: str | None) List[str][source]¶
Returns the tags associated with the symbol
- Parameters:
type (QgsStyle.StyleEntity) – is either SymbolEntity or ColorrampEntity
symbol (Optional[str]) – is the name of the symbol or color ramp
- Return type:
List[str]
- Returns:
A QStringList of the tags that have been applied to that symbol/colorramp
- textFormat(self, name: str | None) QgsTextFormat[source]¶
Returns the text format with the specified
name.Added in version 3.10.
- Parameters:
name (Optional[str])
- Return type:
- signal textFormatAdded[source]¶
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.
- signal textFormatChanged[source]¶
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.
- textFormatCount(self) int[source]¶
Returns count of text formats in the style.
Added in version 3.10.
- Return type:
int
- textFormatId(self, name: str | None) int[source]¶
Returns the ID in the style database for the given text format by
name. Returns 0 if the text format was not found.Added in version 3.10.
- Parameters:
name (Optional[str])
- Return type:
int
- textFormatNames(self) List[str][source]¶
Returns a list of names of text formats in the style.
Added in version 3.10.
- Return type:
List[str]
- signal textFormatRemoved[source]¶
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.
- signal textFormatRenamed[source]¶
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.