QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Friends | List of all members
QgsStyle Class Reference

#include <qgsstyle.h>

Inheritance diagram for QgsStyle:
Inheritance graph
[legend]

Public Types

enum  StyleEntity {
  SymbolEntity , TagEntity , ColorrampEntity , SmartgroupEntity ,
  TextFormatEntity , LabelSettingsEntity , LegendPatchShapeEntity , Symbol3DEntity
}
 Enum for Entities involved in a style. More...
 
enum class  TextFormatContext : int { Labeling }
 Text format context. More...
 

Public Slots

void triggerIconRebuild ()
 Triggers emission of the rebuildIconPreviews() signal.
 

Signals

void aboutToBeDestroyed ()
 Emitted just before the style object is destroyed.
 
void entityAdded (QgsStyle::StyleEntity entity, const QString &name)
 Emitted every time a new entity has been added to the database.
 
void entityChanged (QgsStyle::StyleEntity entity, const QString &name)
 Emitted whenever an entity's definition is changed.
 
void entityRemoved (QgsStyle::StyleEntity entity, const QString &name)
 Emitted whenever an entity of the specified type is removed from the style and the database has been updated as a result.
 
void entityRenamed (QgsStyle::StyleEntity entity, const QString &oldName, const QString &newName)
 Emitted whenever a entity of the specified type has been renamed from oldName to newName.
 
void entityTagsChanged (QgsStyle::StyleEntity entity, const QString &name, const QStringList &newTags)
 Emitted whenever an entity's tags are changed.
 
void favoritedChanged (QgsStyle::StyleEntity entity, const QString &name, bool isFavorite)
 Emitted whenever an entity is either favorited or un-favorited.
 
void groupsModified ()
 Emitted every time a tag or smartgroup has been added, removed, or renamed.
 
void initialized ()
 Emitted when the style database has been fully initialized.
 
void labelSettingsAdded (const QString &name)
 Emitted whenever label settings have been added to the style and the database has been updated as a result.
 
void labelSettingsChanged (const QString &name)
 Emitted whenever a label setting's definition is changed.
 
void labelSettingsRemoved (const QString &name)
 Emitted whenever label settings have been removed from the style and the database has been updated as a result.
 
void labelSettingsRenamed (const QString &oldName, const QString &newName)
 Emitted whenever label settings have been renamed from oldName to newName.
 
void rampAdded (const QString &name)
 Emitted whenever a color ramp has been added to the style and the database has been updated as a result.
 
void rampChanged (const QString &name)
 Emitted whenever a color ramp's definition is changed.
 
void rampRemoved (const QString &name)
 Emitted whenever a color ramp has been removed from the style and the database has been updated as a result.
 
void rampRenamed (const QString &oldName, const QString &newName)
 Emitted whenever a color ramp has been renamed from oldName to newName.
 
void rebuildIconPreviews ()
 Emitted whenever icon previews for entities in the style must be rebuilt.
 
void symbolChanged (const QString &name)
 Emitted whenever a symbol's definition is changed.
 
void symbolRemoved (const QString &name)
 Emitted whenever a symbol has been removed from the style and the database has been updated as a result.
 
void symbolRenamed (const QString &oldName, const QString &newName)
 Emitted whenever a symbol has been renamed from oldName to newName.
 
void symbolSaved (const QString &name, QgsSymbol *symbol)
 Emitted every time a new symbol has been added to the database.
 
void textFormatAdded (const QString &name)
 Emitted whenever a text format has been added to the style and the database has been updated as a result.
 
void textFormatChanged (const QString &name)
 Emitted whenever a text format's definition is changed.
 
void textFormatRemoved (const QString &name)
 Emitted whenever a text format has been removed from the style and the database has been updated as a result.
 
void textFormatRenamed (const QString &oldName, const QString &newName)
 Emitted whenever a text format has been renamed from oldName to newName.
 

Public Member Functions

 QgsStyle (QObject *parent=nullptr)
 Constructor for QgsStyle, with the specified parent object.
 
 ~QgsStyle () override
 
bool addColorRamp (const QString &name, QgsColorRamp *colorRamp, bool update=false)
 Adds a color ramp to the style.
 
bool addEntity (const QString &name, const QgsStyleEntityInterface *entity, bool update=false)
 Adds an entity to the style, with the specified name.
 
bool addFavorite (StyleEntity type, const QString &name)
 Adds the specified symbol to favorites.
 
bool addLabelSettings (const QString &name, const QgsPalLayerSettings &settings, bool update=false)
 Adds label settings with the specified name to the style.
 
bool addLegendPatchShape (const QString &name, const QgsLegendPatchShape &shape, bool update=false)
 Adds a legend patch shape with the specified name to the style.
 
int addSmartgroup (const QString &name, const QString &op, const QgsSmartConditionMap &conditions)
 Adds a new smartgroup to the database and returns the id.
 
int addSmartgroup (const QString &name, const QString &op, const QStringList &matchTag, const QStringList &noMatchTag, const QStringList &matchName, const QStringList &noMatchName)
 Adds a new smartgroup to the database and returns the id.
 
bool addSymbol (const QString &name, QgsSymbol *symbol, bool update=false)
 Adds a symbol to style and takes symbol's ownership.
 
bool addSymbol3D (const QString &name, QgsAbstract3DSymbol *symbol, bool update=false)
 Adds a 3d symbol with the specified name to the style.
 
int addTag (const QString &tagName)
 Adds a new tag and returns the tag's id.
 
bool addTextFormat (const QString &name, const QgsTextFormat &format, bool update=false)
 Adds a text format with the specified name to the style.
 
QStringList allNames (StyleEntity type) const
 Returns a list of the names of all existing entities of the specified type.
 
void clear ()
 Removes all contents of the style.
 
QgsColorRampcolorRamp (const QString &name) const
 Returns a new copy of the specified color ramp.
 
int colorRampCount ()
 Returns count of color ramps.
 
int colorrampId (const QString &name)
 Returns the id in the style database for the given colorramp name returns 0 if not found.
 
QStringList colorRampNames () const
 Returns a list of names of color ramps.
 
const QgsColorRampcolorRampRef (const QString &name) const
 Returns a const pointer to a symbol (doesn't create new instance)
 
bool createDatabase (const QString &filename)
 Creates an on-disk database.
 
bool createMemoryDatabase ()
 Creates a temporary memory database.
 
void createTables ()
 Creates tables structure for new database.
 
QgsLegendPatchShape defaultPatch (Qgis::SymbolType type, QSizeF size) const
 Returns the default legend patch shape for the given symbol type.
 
QList< QList< QPolygonF > > defaultPatchAsQPolygonF (Qgis::SymbolType type, QSizeF size) const
 Returns the default patch geometry for the given symbol type and size as a set of QPolygonF objects (parts and rings).
 
QgsTextFormat defaultTextFormat (QgsStyle::TextFormatContext context=QgsStyle::TextFormatContext::Labeling) const
 Returns the default text format to use for new text based objects in the specified context.
 
bool detagSymbol (StyleEntity type, const QString &symbol)
 Clears the symbol from all attached tags.
 
bool detagSymbol (StyleEntity type, const QString &symbol, const QStringList &tags)
 Detags the symbol with the given list.
 
int entityId (StyleEntity type, const QString &name)
 Returns the id in the style database for the given name of the specified entity type.
 
QString errorString () const
 Returns the last error from a load() operation.
 
bool exportXml (const QString &filename)
 Exports the style as a XML file.
 
QString fileName () const
 Returns the current file name of the style database.
 
QStringList findSymbols (StyleEntity type, const QString &qword)
 Returns the names of the symbols which have a matching 'substring' in its definition.
 
bool importXml (const QString &filename)
 Imports the symbols and colorramps into the default style database from the given XML file.
 
bool isFavorite (StyleEntity type, const QString &name)
 Returns true if the symbol with matching type and name is marked as a favorite.
 
bool isInitialized () const
 Returns true if the style is initialized and ready for use.
 
bool isReadOnly () const
 Returns true if the style is considered a read-only library.
 
QgsPalLayerSettings labelSettings (const QString &name) const
 Returns the label settings with the specified name.
 
int labelSettingsCount () const
 Returns count of label settings in the style.
 
int labelSettingsId (const QString &name)
 Returns the ID in the style database for the given label settings by name.
 
Qgis::GeometryType labelSettingsLayerType (const QString &name) const
 Returns the layer geometry type corresponding to the label settings with the specified name, or Qgis::GeometryType::Unknown if matching label settings are not present.
 
QStringList labelSettingsNames () const
 Returns a list of names of label settings in the style.
 
QgsLegendPatchShape legendPatchShape (const QString &name) const
 Returns the legend patch shape with the specified name.
 
QStringList legendPatchShapeNames () const
 Returns a list of names of legend patch shapes in the style.
 
int legendPatchShapesCount () const
 Returns count of legend patch shapes in the style.
 
Qgis::SymbolType legendPatchShapeSymbolType (const QString &name) const
 Returns the symbol type corresponding to the legend patch shape with the specified name, or QgsSymbol::Hybrid if a matching legend patch shape is not present.
 
bool load (const QString &filename)
 Loads a file into the style.
 
QString name () const
 Returns the name of the style.
 
const QgsSymbolpreviewSymbolForPatchShape (const QgsLegendPatchShape &shape) const
 Returns a symbol to use for rendering preview icons for a patch shape.
 
bool remove (StyleEntity type, int id)
 Removes the specified entity from the database.
 
bool removeColorRamp (const QString &name)
 Removes color ramp from style (and delete it)
 
bool removeEntityByName (StyleEntity type, const QString &name)
 Removes the entry of the specified type with matching name from the database.
 
bool removeFavorite (StyleEntity type, const QString &name)
 Removes the specified symbol from favorites.
 
bool removeLabelSettings (const QString &name)
 Removes label settings from the style.
 
bool removeSymbol (const QString &name)
 Removes symbol from style (and delete it)
 
bool removeTextFormat (const QString &name)
 Removes a text format from the style.
 
bool rename (StyleEntity type, int id, const QString &newName)
 Renames the given entity with the specified id.
 
bool renameColorRamp (const QString &oldName, const QString &newName)
 Changes ramp's name.
 
bool renameEntity (StyleEntity type, const QString &oldName, const QString &newName)
 Renames an entity of the specified type from oldName to newName.
 
bool renameLabelSettings (const QString &oldName, const QString &newName)
 Changes a label setting's name.
 
bool renameLegendPatchShape (const QString &oldName, const QString &newName)
 Changes a legend patch shape's name.
 
bool renameSymbol (const QString &oldName, const QString &newName)
 Renames a symbol from oldName to newName.
 
bool renameSymbol3D (const QString &oldName, const QString &newName)
 Changes a 3d symbol's name.
 
bool renameTextFormat (const QString &oldName, const QString &newName)
 Changes a text format's name.
 
Q_DECL_DEPRECATED bool save (const QString &filename=QString())
 Saves style into a file.
 
bool saveColorRamp (const QString &name, QgsColorRamp *ramp, bool favorite, const QStringList &tags)
 Adds the colorramp to the database.
 
bool saveLabelSettings (const QString &name, const QgsPalLayerSettings &settings, bool favorite, const QStringList &tags)
 Adds label settings to the database.
 
bool saveLegendPatchShape (const QString &name, const QgsLegendPatchShape &shape, bool favorite, const QStringList &tags)
 Adds a legend patch shape to the database.
 
bool saveSymbol (const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
 Adds the symbol to the database with tags.
 
bool saveSymbol3D (const QString &name, QgsAbstract3DSymbol *symbol, bool favorite, const QStringList &tags)
 Adds a 3d symbol to the database.
 
bool saveTextFormat (const QString &name, const QgsTextFormat &format, bool favorite, const QStringList &tags)
 Adds a text format to the database.
 
void setFileName (const QString &filename)
 Sets the current file name of the style database.
 
void setName (const QString &name)
 Sets the name of the style.
 
void setReadOnly (bool readOnly)
 Sets whether the style is considered a read-only library.
 
QgsSmartConditionMap smartgroup (int id)
 Returns the QgsSmartConditionMap for the given id.
 
int smartgroupId (const QString &smartgroup)
 Returns the database id for the given smartgroup name.
 
QStringList smartgroupNames () const
 Returns the smart groups list.
 
QString smartgroupOperator (int id)
 Returns the operator for the smartgroup.
 
QgsSymbolGroupMap smartgroupsListMap ()
 Returns the smart groups map with id as key and name as value.
 
QgsSymbolsymbol (const QString &name)
 Returns a NEW copy of symbol.
 
QgsAbstract3DSymbolsymbol3D (const QString &name) const
 Returns a new copy of the 3D symbol with the specified name.
 
QList< Qgis::GeometryTypesymbol3DCompatibleGeometryTypes (const QString &name) const
 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.
 
int symbol3DCount () const
 Returns count of 3D symbols in the style.
 
QStringList symbol3DNames () const
 Returns a list of names of 3d symbols in the style.
 
int symbolCount ()
 Returns count of symbols in style.
 
bool symbolHasTag (StyleEntity type, const QString &symbol, const QString &tag)
 Returns whether a given tag is associated with the symbol.
 
int symbolId (const QString &name)
 Returns the id in the style database for the given symbol name returns 0 if not found.
 
QStringList symbolNames () const
 Returns a list of names of symbols.
 
const QgsSymbolsymbolRef (const QString &name) const
 Returns a const pointer to a symbol (doesn't create new instance)
 
QStringList symbolsOfFavorite (StyleEntity type) const
 Returns the symbol names which are flagged as favorite.
 
QStringList symbolsOfSmartgroup (StyleEntity type, int id)
 Returns the symbols for the smartgroup.
 
QStringList symbolsWithTag (StyleEntity type, int tagid) const
 Returns the symbol names with which have the given tag.
 
QString tag (int id) const
 Returns the tag name for the given id.
 
int tagId (const QString &tag)
 Returns the database id for the given tag name.
 
QStringList tags () const
 Returns a list of all tags in the style database.
 
QStringList tagsOfSymbol (StyleEntity type, const QString &symbol)
 Returns the tags associated with the symbol.
 
bool tagSymbol (StyleEntity type, const QString &symbol, const QStringList &tags)
 Tags the symbol with the tags in the list.
 
QgsTextFormat textFormat (const QString &name) const
 Returns the text format with the specified name.
 
int textFormatCount () const
 Returns count of text formats in the style.
 
int textFormatId (const QString &name)
 Returns the ID in the style database for the given text format by name.
 
QStringList textFormatNames () const
 Returns a list of names of text formats in the style.
 

Static Public Member Functions

static void cleanDefaultStyle ()
 Deletes the default style. Only to be used by QgsApplication::exitQgis()
 
static QgsStyledefaultStyle (bool initialize=true)
 Returns the default application-wide style.
 
static QgsTextFormat defaultTextFormatForProject (QgsProject *project, QgsStyle::TextFormatContext context=QgsStyle::TextFormatContext::Labeling)
 Returns the default text format to use for new text based objects for the specified project, in the specified context.
 
static bool isXmlStyleFile (const QString &path)
 Tests if the file at path is a QGIS style XML file.
 

Friends

class Qgs3D
 
class TestStyle
 

Detailed Description

Definition at line 159 of file qgsstyle.h.

Member Enumeration Documentation

◆ StyleEntity

Enum for Entities involved in a style.

The enumerator is used for identifying the entity being operated on when generic database functions are being run.

See also
rename(), remove(), symbolsOfFavorite(), symbolsWithTag(), symbolsOfSmartgroup()
Enumerator
SymbolEntity 

Symbols.

TagEntity 

Tags.

ColorrampEntity 

Color ramps.

SmartgroupEntity 

Smart groups.

TextFormatEntity 

Text formats.

LabelSettingsEntity 

Label settings.

LegendPatchShapeEntity 

Legend patch shape (since QGIS 3.14)

Symbol3DEntity 

3D symbol entity (since QGIS 3.14)

Definition at line 178 of file qgsstyle.h.

◆ TextFormatContext

enum class QgsStyle::TextFormatContext : int
strong

Text format context.

Since
QGIS 3.20
Enumerator
Labeling 

Text format used in labeling.

Definition at line 785 of file qgsstyle.h.

Constructor & Destructor Documentation

◆ QgsStyle()

QgsStyle::QgsStyle ( QObject *  parent = nullptr)

Constructor for QgsStyle, with the specified parent object.

Definition at line 79 of file qgsstyle.cpp.

◆ ~QgsStyle()

QgsStyle::~QgsStyle ( )
override

Definition at line 95 of file qgsstyle.cpp.

Member Function Documentation

◆ aboutToBeDestroyed

void QgsStyle::aboutToBeDestroyed ( )
signal

Emitted just before the style object is destroyed.

Emitted in the destructor when the style is about to be deleted, but it is still in a perfectly valid state: the last chance for other pieces of code for some cleanup if they use the style.

Since
QGIS 3.26

◆ addColorRamp()

bool QgsStyle::addColorRamp ( const QString &  name,
QgsColorRamp colorRamp,
bool  update = false 
)

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
nameis the name of the color ramp being added or updated
colorRampis the color ramp. Ownership is transferred.
updateset to true when the style database has to be updated, by default it is false
Returns
success status of the operation

Definition at line 345 of file qgsstyle.cpp.

◆ addEntity()

bool QgsStyle::addEntity ( const QString &  name,
const QgsStyleEntityInterface entity,
bool  update = false 
)

Adds an entity to the style, with the specified name.

Ownership is not transferred.

If update is true then the style database is updated automatically as a result.

Returns true if the add operation was successful.

Note
Adding an entity with the name of existing one replaces the existing one automatically.
Since
QGIS 3.10

Definition at line 111 of file qgsstyle.cpp.

◆ addFavorite()

bool QgsStyle::addFavorite ( StyleEntity  type,
const QString &  name 
)

Adds the specified symbol to favorites.

Parameters
typeis either SymbolEntity of ColorrampEntity
nameis the name of the symbol or coloramp whose is to be added to favorites
Returns
returns the success state as bool

Definition at line 1658 of file qgsstyle.cpp.

◆ addLabelSettings()

bool QgsStyle::addLabelSettings ( const QString &  name,
const QgsPalLayerSettings settings,
bool  update = false 
)

Adds label settings with the specified name to the style.

If update is set to true, the style database will be automatically updated with the new text format.

Returns true if the operation was successful.

Note
Adding label settings with the name of existing ones replaces them.
Since
QGIS 3.10

Definition at line 390 of file qgsstyle.cpp.

◆ addLegendPatchShape()

bool QgsStyle::addLegendPatchShape ( const QString &  name,
const QgsLegendPatchShape shape,
bool  update = false 
)

Adds a legend patch shape with the specified name to the style.

If update is set to true, the style database will be automatically updated with the new legend patch shape.

Returns true if the operation was successful.

Note
Adding legend patch shapes with the name of existing ones replaces them.
Since
QGIS 3.14

Definition at line 411 of file qgsstyle.cpp.

◆ addSmartgroup() [1/2]

int QgsStyle::addSmartgroup ( const QString &  name,
const QString &  op,
const QgsSmartConditionMap conditions 
)

Adds a new smartgroup to the database and returns the id.

Parameters
nameis the name of the new Smart Group to be added
opis the operator between the conditions; AND/OR as QString
conditionsare the smart group conditions
Note
Not available from Python bindings

Definition at line 2301 of file qgsstyle.cpp.

◆ addSmartgroup() [2/2]

int QgsStyle::addSmartgroup ( const QString &  name,
const QString &  op,
const QStringList &  matchTag,
const QStringList &  noMatchTag,
const QStringList &  matchName,
const QStringList &  noMatchName 
)

Adds a new smartgroup to the database and returns the id.

Parameters
nameis the name of the new Smart Group to be added
opis the operator between the conditions; AND/OR as QString
matchTaglist of strings to match within tags
noMatchTaglist of strings to exclude matches from tags
matchNamelist of string to match within names
noMatchNamelist of strings to exclude matches from names
Since
QGIS 3.4

Definition at line 2309 of file qgsstyle.cpp.

◆ addSymbol()

bool QgsStyle::addSymbol ( const QString &  name,
QgsSymbol symbol,
bool  update = false 
)

Adds a symbol to style and takes symbol's ownership.

Note
Adding a symbol with the name of existing one replaces it.
Parameters
nameis the name of the symbol being added or updated
symbolis the Vector symbol
updateset to true when the style database has to be updated, by default it is false
Returns
success status of the operation

Definition at line 223 of file qgsstyle.cpp.

◆ addSymbol3D()

bool QgsStyle::addSymbol3D ( const QString &  name,
QgsAbstract3DSymbol symbol,
bool  update = false 
)

Adds a 3d symbol with the specified name to the style.

Ownership of symbol is transferred.

If update is set to true, the style database will be automatically updated with the new legend patch shape.

Returns true if the operation was successful.

Note
Adding 3d symbols with the name of existing ones replaces them.
Since
QGIS 3.16

Definition at line 432 of file qgsstyle.cpp.

◆ addTag()

int QgsStyle::addTag ( const QString &  tagName)

Adds a new tag and returns the tag's id.

Parameters
tagNamethe name of the new tag to be created
Returns
returns an int, which is the database id of the new tag created, 0 if the tag couldn't be created

Definition at line 1413 of file qgsstyle.cpp.

◆ addTextFormat()

bool QgsStyle::addTextFormat ( const QString &  name,
const QgsTextFormat format,
bool  update = false 
)

Adds a text format with the specified name to the style.

If update is set to true, the style database will be automatically updated with the new text format.

Returns true if the operation was successful.

Note
Adding a text format with the name of existing one replaces it.
Since
QGIS 3.10

Definition at line 369 of file qgsstyle.cpp.

◆ allNames()

QStringList QgsStyle::allNames ( QgsStyle::StyleEntity  type) const

Returns a list of the names of all existing entities of the specified type.

Since
QGIS 3.10

Definition at line 2270 of file qgsstyle.cpp.

◆ cleanDefaultStyle()

void QgsStyle::cleanDefaultStyle ( )
static

Deletes the default style. Only to be used by QgsApplication::exitQgis()

Definition at line 202 of file qgsstyle.cpp.

◆ clear()

void QgsStyle::clear ( )

Removes all contents of the style.

Definition at line 208 of file qgsstyle.cpp.

◆ colorRamp()

QgsColorRamp * QgsStyle::colorRamp ( const QString &  name) const

Returns a new copy of the specified color ramp.

The caller takes responsibility for deleting the returned object.

Definition at line 494 of file qgsstyle.cpp.

◆ colorRampCount()

int QgsStyle::colorRampCount ( )

Returns count of color ramps.

Definition at line 505 of file qgsstyle.cpp.

◆ colorrampId()

int QgsStyle::colorrampId ( const QString &  name)

Returns the id in the style database for the given colorramp name returns 0 if not found.

Definition at line 2147 of file qgsstyle.cpp.

◆ colorRampNames()

QStringList QgsStyle::colorRampNames ( ) const

Returns a list of names of color ramps.

Definition at line 510 of file qgsstyle.cpp.

◆ colorRampRef()

const QgsColorRamp * QgsStyle::colorRampRef ( const QString &  name) const

Returns a const pointer to a symbol (doesn't create new instance)

Definition at line 500 of file qgsstyle.cpp.

◆ createDatabase()

bool QgsStyle::createDatabase ( const QString &  filename)

Creates an on-disk database.

This function creates a new on-disk permanent style database.

Returns
returns the success state of the database creation
See also
createMemoryDatabase()

Definition at line 548 of file qgsstyle.cpp.

◆ createMemoryDatabase()

bool QgsStyle::createMemoryDatabase ( )

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.

Returns
returns the success state of the temporary memory database creation
See also
createDatabase()

Definition at line 563 of file qgsstyle.cpp.

◆ createTables()

void QgsStyle::createTables ( )

Creates tables structure for new database.

This function is used to create the tables structure in a newly-created database.

See also
createDatabase()
createMemoryDatabase()

Definition at line 578 of file qgsstyle.cpp.

◆ defaultPatch()

QgsLegendPatchShape QgsStyle::defaultPatch ( Qgis::SymbolType  type,
QSizeF  size 
) const

Returns the default legend patch shape for the given symbol type.

See also
defaultPatchAsQPolygonF()
Since
QGIS 3.14

Definition at line 1189 of file qgsstyle.cpp.

◆ defaultPatchAsQPolygonF()

QList< QList< QPolygonF > > QgsStyle::defaultPatchAsQPolygonF ( Qgis::SymbolType  type,
QSizeF  size 
) const

Returns the default patch geometry for the given symbol type and size as a set of QPolygonF objects (parts and rings).

See also
defaultPatch()
Since
QGIS 3.14

Definition at line 1231 of file qgsstyle.cpp.

◆ defaultStyle()

QgsStyle * QgsStyle::defaultStyle ( bool  initialize = true)
static

Returns the default application-wide style.

Since QGIS 3.36, the initialize argument can be set to false to 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.

Definition at line 145 of file qgsstyle.cpp.

◆ defaultTextFormat()

QgsTextFormat QgsStyle::defaultTextFormat ( QgsStyle::TextFormatContext  context = QgsStyle::TextFormatContext::Labeling) const

Returns the default text format to use for new text based objects in the specified context.

Since
QGIS 3.20

Definition at line 1244 of file qgsstyle.cpp.

◆ defaultTextFormatForProject()

QgsTextFormat QgsStyle::defaultTextFormatForProject ( QgsProject project,
QgsStyle::TextFormatContext  context = QgsStyle::TextFormatContext::Labeling 
)
static

Returns the default text format to use for new text based objects for the specified project, in the specified context.

Since
QGIS 3.26

Definition at line 1249 of file qgsstyle.cpp.

◆ detagSymbol() [1/2]

bool QgsStyle::detagSymbol ( StyleEntity  type,
const QString &  symbol 
)

Clears the symbol from all attached tags.

Removes all tags for the specified symbol or colorramp

Parameters
typeis either SymbolEntity or ColorrampEntity
symbolis the name of the symbol or colorramp
Returns
returns the success state of the operation

Definition at line 1905 of file qgsstyle.cpp.

◆ detagSymbol() [2/2]

bool QgsStyle::detagSymbol ( StyleEntity  type,
const QString &  symbol,
const QStringList &  tags 
)

Detags the symbol with the given list.

Removes the given tags for the specified symbol or colorramp

Parameters
typeis either SymbolEntity or ColorrampEntity
symbolis the name of the symbol or colorramp
tagsis the list of tags that are to be removed as QStringList
Returns
returns the success state of the operation

Definition at line 1850 of file qgsstyle.cpp.

◆ entityAdded

void QgsStyle::entityAdded ( QgsStyle::StyleEntity  entity,
const QString &  name 
)
signal

Emitted every time a new entity has been added to the database.

Since
QGIS 3.14

◆ entityChanged

void QgsStyle::entityChanged ( QgsStyle::StyleEntity  entity,
const QString &  name 
)
signal

Emitted whenever an entity's definition is changed.

This does not include name or tag changes.

Since
QGIS 3.14

◆ entityId()

int QgsStyle::entityId ( QgsStyle::StyleEntity  type,
const QString &  name 
)

Returns the id in the style database for the given name of the specified entity type.

Returns 0 if not found.

Definition at line 2142 of file qgsstyle.cpp.

◆ entityRemoved

void QgsStyle::entityRemoved ( QgsStyle::StyleEntity  entity,
const QString &  name 
)
signal

Emitted whenever an entity of the specified type is removed from the style and the database has been updated as a result.

Since
QGIS 3.14

◆ entityRenamed

void QgsStyle::entityRenamed ( QgsStyle::StyleEntity  entity,
const QString &  oldName,
const QString &  newName 
)
signal

Emitted whenever a entity of the specified type has been renamed from oldName to newName.

Since
QGIS 3.14

◆ entityTagsChanged

void QgsStyle::entityTagsChanged ( QgsStyle::StyleEntity  entity,
const QString &  name,
const QStringList &  newTags 
)
signal

Emitted whenever an entity's tags are changed.

Since
QGIS 3.4

◆ errorString()

QString QgsStyle::errorString ( ) const
inline

Returns the last error from a load() operation.

See also
load()

Definition at line 890 of file qgsstyle.h.

◆ exportXml()

bool QgsStyle::exportXml ( const QString &  filename)

Exports the style as a XML file.

Definition at line 2567 of file qgsstyle.cpp.

◆ favoritedChanged

void QgsStyle::favoritedChanged ( QgsStyle::StyleEntity  entity,
const QString &  name,
bool  isFavorite 
)
signal

Emitted whenever an entity is either favorited or un-favorited.

Since
QGIS 3.4

◆ fileName()

QString QgsStyle::fileName ( ) const
inline

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
setFileName()

Definition at line 901 of file qgsstyle.h.

◆ findSymbols()

QStringList QgsStyle::findSymbols ( StyleEntity  type,
const QString &  qword 
)

Returns the names of the symbols which have a matching 'substring' in its definition.

Parameters
typeis either SymbolEntity or ColorrampEntity
qwordis the query string to search the symbols or colorramps.
Returns
A QStringList of the matched symbols or colorramps

Definition at line 1720 of file qgsstyle.cpp.

◆ groupsModified

void QgsStyle::groupsModified ( )
signal

Emitted every time a tag or smartgroup has been added, removed, or renamed.

◆ importXml()

bool QgsStyle::importXml ( const QString &  filename)

Imports the symbols and colorramps into the default style database from the given XML file.

Definition at line 2730 of file qgsstyle.cpp.

◆ initialized

void QgsStyle::initialized ( )
signal

Emitted when the style database has been fully initialized.

This signals is only emitted by the QgsStyle::defaultStyle() instance, and only when the defaultStyle() has been lazily initialized.

Since
QGIS 3.36

◆ isFavorite()

bool QgsStyle::isFavorite ( QgsStyle::StyleEntity  type,
const QString &  name 
)

Returns true if the symbol with matching type and name is marked as a favorite.

Since
QGIS 3.10

Definition at line 1994 of file qgsstyle.cpp.

◆ isInitialized()

bool QgsStyle::isInitialized ( ) const
inline

Returns true if the style is initialized and ready for use.

Most instances of QgsStyle will already be initialized. However, if the style is the QgsStyle::defaultStyle() object it may have been created using lazy initialization and will return false until it is initialized().

Since
QGIS 3.36

Definition at line 215 of file qgsstyle.h.

◆ isReadOnly()

bool QgsStyle::isReadOnly ( ) const

Returns true if 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
setReadOnly()
Since
QGIS 3.26

Definition at line 3092 of file qgsstyle.cpp.

◆ isXmlStyleFile()

bool QgsStyle::isXmlStyleFile ( const QString &  path)
static

Tests if the file at path is a QGIS style XML file.

This method samples only the first line in the file, so is safe to call on large xml files.

Since
QGIS 3.6

Definition at line 3067 of file qgsstyle.cpp.

◆ labelSettings()

QgsPalLayerSettings QgsStyle::labelSettings ( const QString &  name) const

Returns the label settings with the specified name.

Since
QGIS 3.10

Definition at line 2172 of file qgsstyle.cpp.

◆ labelSettingsAdded

void QgsStyle::labelSettingsAdded ( const QString &  name)
signal

Emitted whenever label settings have been added to the style and the database has been updated as a result.

See also
labelSettingsRemoved()
symbolSaved()
Since
QGIS 3.10

◆ labelSettingsChanged

void QgsStyle::labelSettingsChanged ( const QString &  name)
signal

Emitted whenever a label setting's definition is changed.

This does not include name or tag changes.

See also
labelSettingsAdded()
Since
QGIS 3.10

◆ labelSettingsCount()

int QgsStyle::labelSettingsCount ( ) const

Returns count of label settings in the style.

Since
QGIS 3.10

Definition at line 2221 of file qgsstyle.cpp.

◆ labelSettingsId()

int QgsStyle::labelSettingsId ( const QString &  name)

Returns the ID in the style database for the given label settings by name.

Returns 0 if the label settings were not found.

Since
QGIS 3.10

Definition at line 2231 of file qgsstyle.cpp.

◆ labelSettingsLayerType()

Qgis::GeometryType QgsStyle::labelSettingsLayerType ( const QString &  name) const

Returns the layer geometry type corresponding to the label settings with the specified name, or Qgis::GeometryType::Unknown if matching label settings are not present.

Since
QGIS 3.10

Definition at line 2213 of file qgsstyle.cpp.

◆ labelSettingsNames()

QStringList QgsStyle::labelSettingsNames ( ) const

Returns a list of names of label settings in the style.

Since
QGIS 3.10

Definition at line 2226 of file qgsstyle.cpp.

◆ labelSettingsRemoved

void QgsStyle::labelSettingsRemoved ( const QString &  name)
signal

Emitted whenever label settings have been removed from the style and the database has been updated as a result.

See also
labelSettingsAdded()
symbolRemoved()
Since
QGIS 3.10

◆ labelSettingsRenamed

void QgsStyle::labelSettingsRenamed ( const QString &  oldName,
const QString &  newName 
)
signal

Emitted whenever label settings have been renamed from oldName to newName.

See also
symbolRenamed()
Since
QGIS 3.10

◆ legendPatchShape()

QgsLegendPatchShape QgsStyle::legendPatchShape ( const QString &  name) const

Returns the legend patch shape with the specified name.

Since
QGIS 3.14

Definition at line 2177 of file qgsstyle.cpp.

◆ legendPatchShapeNames()

QStringList QgsStyle::legendPatchShapeNames ( ) const

Returns a list of names of legend patch shapes in the style.

Since
QGIS 3.14

Definition at line 2236 of file qgsstyle.cpp.

◆ legendPatchShapesCount()

int QgsStyle::legendPatchShapesCount ( ) const

Returns count of legend patch shapes in the style.

Since
QGIS 3.14

Definition at line 2182 of file qgsstyle.cpp.

◆ legendPatchShapeSymbolType()

Qgis::SymbolType QgsStyle::legendPatchShapeSymbolType ( const QString &  name) const

Returns the symbol type corresponding to the legend patch shape with the specified name, or QgsSymbol::Hybrid if a matching legend patch shape is not present.

Since
QGIS 3.14

Definition at line 2187 of file qgsstyle.cpp.

◆ load()

bool QgsStyle::load ( const QString &  filename)

Loads a file into the style.

This function will load an on-disk database and populate styles.

Parameters
filenamelocation of the database to load styles from
Returns
true if the database was successfully loaded. If false is returned then a detailed error message can be retrieved via errorString().
See also
errorString()

Definition at line 638 of file qgsstyle.cpp.

◆ name()

QString QgsStyle::name ( ) const

Returns the name of the style.

See also
setName()
Since
QGIS 3.26

Definition at line 106 of file qgsstyle.cpp.

◆ previewSymbolForPatchShape()

const QgsSymbol * QgsStyle::previewSymbolForPatchShape ( const QgsLegendPatchShape shape) const

Returns a symbol to use for rendering preview icons for a patch shape.

Ownership of the symbol is not transferred.

Since
QGIS 3.14

Definition at line 2241 of file qgsstyle.cpp.

◆ rampAdded

void QgsStyle::rampAdded ( const QString &  name)
signal

Emitted whenever a color ramp has been added to the style and the database has been updated as a result.

See also
rampRemoved()
symbolSaved()
Since
QGIS 3.4

◆ rampChanged

void QgsStyle::rampChanged ( const QString &  name)
signal

Emitted whenever a color ramp's definition is changed.

This does not include name or tag changes.

See also
rampAdded()
Since
QGIS 3.4

◆ rampRemoved

void QgsStyle::rampRemoved ( const QString &  name)
signal

Emitted whenever a color ramp has been removed from the style and the database has been updated as a result.

See also
rampAdded()
symbolRemoved()
Since
QGIS 3.4

◆ rampRenamed

void QgsStyle::rampRenamed ( const QString &  oldName,
const QString &  newName 
)
signal

Emitted whenever a color ramp has been renamed from oldName to newName.

See also
symbolRenamed()
Since
QGIS 3.4

◆ rebuildIconPreviews

void QgsStyle::rebuildIconPreviews ( )
signal

Emitted whenever icon previews for entities in the style must be rebuilt.

Since
QGIS 3.26

◆ remove()

bool QgsStyle::remove ( StyleEntity  type,
int  id 
)

Removes the specified entity from the database.

Parameters
typeis any of the style entities. Refer enum StyleEntity.
idis the database id of the entity to be removed
See also
removeEntityByName()

Definition at line 1488 of file qgsstyle.cpp.

◆ removeColorRamp()

bool QgsStyle::removeColorRamp ( const QString &  name)

Removes color ramp from style (and delete it)

Definition at line 489 of file qgsstyle.cpp.

◆ removeEntityByName()

bool QgsStyle::removeEntityByName ( QgsStyle::StyleEntity  type,
const QString &  name 
)

Removes the entry of the specified type with matching name from the database.

See also
remove()
Since
QGIS 3.14

Definition at line 1534 of file qgsstyle.cpp.

◆ removeFavorite()

bool QgsStyle::removeFavorite ( StyleEntity  type,
const QString &  name 
)

Removes the specified symbol from favorites.

Parameters
typeis either SymbolEntity of ColorrampEntity
nameis the name of the symbol or coloramp whose is to be removed from favorites
Returns
returns the success state as bool

Definition at line 1694 of file qgsstyle.cpp.

◆ removeLabelSettings()

bool QgsStyle::removeLabelSettings ( const QString &  name)

Removes label settings from the style.

Since
QGIS 3.10

Definition at line 1085 of file qgsstyle.cpp.

◆ removeSymbol()

bool QgsStyle::removeSymbol ( const QString &  name)

Removes symbol from style (and delete it)

Definition at line 283 of file qgsstyle.cpp.

◆ removeTextFormat()

bool QgsStyle::removeTextFormat ( const QString &  name)

Removes a text format from the style.

Since
QGIS 3.10

Definition at line 1009 of file qgsstyle.cpp.

◆ rename()

bool QgsStyle::rename ( StyleEntity  type,
int  id,
const QString &  newName 
)

Renames the given entity with the specified id.

Parameters
typeis any of the style entities. Refer enum StyleEntity.
idis the database id of the entity which is to be renamed
newNameis the new name of the entity

Definition at line 1453 of file qgsstyle.cpp.

◆ renameColorRamp()

bool QgsStyle::renameColorRamp ( const QString &  oldName,
const QString &  newName 
)

Changes ramp's name.

Definition at line 938 of file qgsstyle.cpp.

◆ renameEntity()

bool QgsStyle::renameEntity ( QgsStyle::StyleEntity  type,
const QString &  oldName,
const QString &  newName 
)

Renames an entity of the specified type from oldName to newName.

Returns true if the entity was successfully renamed.

Since
QGIS 3.14

Definition at line 288 of file qgsstyle.cpp.

◆ renameLabelSettings()

bool QgsStyle::renameLabelSettings ( const QString &  oldName,
const QString &  newName 
)

Changes a label setting's name.

Since
QGIS 3.10

Definition at line 1090 of file qgsstyle.cpp.

◆ renameLegendPatchShape()

bool QgsStyle::renameLegendPatchShape ( const QString &  oldName,
const QString &  newName 
)

Changes a legend patch shape's name.

Since
QGIS 3.14

Definition at line 1155 of file qgsstyle.cpp.

◆ renameSymbol()

bool QgsStyle::renameSymbol ( const QString &  oldName,
const QString &  newName 
)

Renames a symbol from oldName to newName.

Returns true if symbol was successfully renamed.

Definition at line 898 of file qgsstyle.cpp.

◆ renameSymbol3D()

bool QgsStyle::renameSymbol3D ( const QString &  oldName,
const QString &  newName 
)

Changes a 3d symbol's name.

Since
QGIS 3.16

Definition at line 1294 of file qgsstyle.cpp.

◆ renameTextFormat()

bool QgsStyle::renameTextFormat ( const QString &  oldName,
const QString &  newName 
)

Changes a text format's name.

Since
QGIS 3.10

Definition at line 1014 of file qgsstyle.cpp.

◆ save()

bool QgsStyle::save ( const QString &  filename = QString())

Saves style into a file.

The current fileName() will be used if no explicit filename is specified.

Returns
true if the style was successfully saved. If false is returned then a detailed error message can be retrieved via errorString().
See also
fileName()
load()
errorString()
Deprecated:
This function has no effect.

Definition at line 883 of file qgsstyle.cpp.

◆ saveColorRamp()

bool QgsStyle::saveColorRamp ( const QString &  name,
QgsColorRamp ramp,
bool  favorite,
const QStringList &  tags 
)

Adds the colorramp to the database.

Parameters
nameis the name of the colorramp as QString
rampis the pointer to the new QgsColorRamp being saved
favoriteis a boolean value to specify whether the colorramp should be added to favorites
tagsis a list of tags that are associated with the color ramp as a QStringList.
Returns
returns the success state of the save operation

Definition at line 453 of file qgsstyle.cpp.

◆ saveLabelSettings()

bool QgsStyle::saveLabelSettings ( const QString &  name,
const QgsPalLayerSettings settings,
bool  favorite,
const QStringList &  tags 
)

Adds label settings to the database.

Parameters
nameis the name of the label settings
settingslabel settings to save
favoriteis a boolean value to specify whether the label settings should be added to favorites
tagsis a list of tags that are associated with the label settings
Returns
returns the success state of the save operation

Definition at line 1049 of file qgsstyle.cpp.

◆ saveLegendPatchShape()

bool QgsStyle::saveLegendPatchShape ( const QString &  name,
const QgsLegendPatchShape shape,
bool  favorite,
const QStringList &  tags 
)

Adds a legend patch shape to the database.

Parameters
nameis the name of the legend patch shape
shapelegend patch shape to save
favoriteis a boolean value to specify whether the legend patch shape should be added to favorites
tagsis a list of tags that are associated with the legend patch shape
Returns
returns the success state of the save operation
Since
QGIS 3.14

Definition at line 1125 of file qgsstyle.cpp.

◆ saveSymbol()

bool QgsStyle::saveSymbol ( const QString &  name,
QgsSymbol symbol,
bool  favorite,
const QStringList &  tags 
)

Adds the symbol to the database with tags.

Parameters
nameis the name of the symbol as QString
symbolis the pointer to the new QgsSymbol being saved
favoriteis a boolean value to specify whether the symbol should be added to favorites
tagsis a list of tags that are associated with the symbol as a QStringList.
Returns
returns the success state of the save operation

Definition at line 247 of file qgsstyle.cpp.

◆ saveSymbol3D()

bool QgsStyle::saveSymbol3D ( const QString &  name,
QgsAbstract3DSymbol symbol,
bool  favorite,
const QStringList &  tags 
)

Adds a 3d symbol to the database.

Parameters
nameis the name of the 3d symbol
symbol3d symbol to save. Ownership is transferred.
favoriteis a boolean value to specify whether the 3d symbol should be added to favorites
tagsis a list of tags that are associated with the 3d symbol
Returns
returns the success state of the save operation
Since
QGIS 3.16

Definition at line 1263 of file qgsstyle.cpp.

◆ saveTextFormat()

bool QgsStyle::saveTextFormat ( const QString &  name,
const QgsTextFormat format,
bool  favorite,
const QStringList &  tags 
)

Adds a text format to the database.

Parameters
nameis the name of the text format
formattext format to save
favoriteis a boolean value to specify whether the text format should be added to favorites
tagsis a list of tags that are associated with the text format
Returns
returns the success state of the save operation

Definition at line 973 of file qgsstyle.cpp.

◆ setFileName()

void QgsStyle::setFileName ( const QString &  filename)

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.

Since
QGIS 3.26

Definition at line 893 of file qgsstyle.cpp.

◆ setName()

void QgsStyle::setName ( const QString &  name)

Sets the name of the style.

See also
name()
Since
QGIS 3.26

Definition at line 101 of file qgsstyle.cpp.

◆ setReadOnly()

void QgsStyle::setReadOnly ( bool  readOnly)

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
isReadOnly()
Since
QGIS 3.26

Definition at line 3097 of file qgsstyle.cpp.

◆ smartgroup()

QgsSmartConditionMap QgsStyle::smartgroup ( int  id)

Returns the QgsSmartConditionMap for the given id.

Definition at line 2497 of file qgsstyle.cpp.

◆ smartgroupId()

int QgsStyle::smartgroupId ( const QString &  smartgroup)

Returns the database id for the given smartgroup name.

Definition at line 2265 of file qgsstyle.cpp.

◆ smartgroupNames()

QStringList QgsStyle::smartgroupNames ( ) const

Returns the smart groups list.

Definition at line 2380 of file qgsstyle.cpp.

◆ smartgroupOperator()

QString QgsStyle::smartgroupOperator ( int  id)

Returns the operator for the smartgroup.

Definition at line 2537 of file qgsstyle.cpp.

◆ smartgroupsListMap()

QgsSymbolGroupMap QgsStyle::smartgroupsListMap ( )

Returns the smart groups map with id as key and name as value.

Definition at line 2355 of file qgsstyle.cpp.

◆ symbol()

QgsSymbol * QgsStyle::symbol ( const QString &  name)

Returns a NEW copy of symbol.

Definition at line 317 of file qgsstyle.cpp.

◆ symbol3D()

QgsAbstract3DSymbol * QgsStyle::symbol3D ( const QString &  name) const

Returns a new copy of the 3D symbol with the specified name.

Since
QGIS 3.16

Definition at line 2195 of file qgsstyle.cpp.

◆ symbol3DCompatibleGeometryTypes()

QList< Qgis::GeometryType > QgsStyle::symbol3DCompatibleGeometryTypes ( const QString &  name) const

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.

Since
QGIS 3.16

Definition at line 2205 of file qgsstyle.cpp.

◆ symbol3DCount()

int QgsStyle::symbol3DCount ( ) const

Returns count of 3D symbols in the style.

Since
QGIS 3.16

Definition at line 2200 of file qgsstyle.cpp.

◆ symbol3DNames()

QStringList QgsStyle::symbol3DNames ( ) const

Returns a list of names of 3d symbols in the style.

Since
QGIS 3.16

Definition at line 1328 of file qgsstyle.cpp.

◆ symbolChanged

void QgsStyle::symbolChanged ( const QString &  name)
signal

Emitted whenever a symbol's definition is changed.

This does not include name or tag changes.

See also
symbolSaved()
Since
QGIS 3.4

◆ symbolCount()

int QgsStyle::symbolCount ( )

Returns count of symbols in style.

Definition at line 334 of file qgsstyle.cpp.

◆ symbolHasTag()

bool QgsStyle::symbolHasTag ( StyleEntity  type,
const QString &  symbol,
const QString &  tag 
)

Returns whether a given tag is associated with the symbol.

Parameters
typeis either SymbolEntity or ColorrampEntity
symbolis the name of the symbol or color ramp
tagthe name of the tag to look for
Returns
A boolean value identicating whether a tag was found attached to the symbol

Definition at line 2032 of file qgsstyle.cpp.

◆ symbolId()

int QgsStyle::symbolId ( const QString &  name)

Returns the id in the style database for the given symbol name returns 0 if not found.

Definition at line 2137 of file qgsstyle.cpp.

◆ symbolNames()

QStringList QgsStyle::symbolNames ( ) const

Returns a list of names of symbols.

Definition at line 339 of file qgsstyle.cpp.

◆ symbolRef()

const QgsSymbol * QgsStyle::symbolRef ( const QString &  name) const

Returns a const pointer to a symbol (doesn't create new instance)

Definition at line 329 of file qgsstyle.cpp.

◆ symbolRemoved

void QgsStyle::symbolRemoved ( const QString &  name)
signal

Emitted whenever a symbol has been removed from the style and the database has been updated as a result.

See also
symbolSaved()
rampRemoved()
Since
QGIS 3.4

◆ symbolRenamed

void QgsStyle::symbolRenamed ( const QString &  oldName,
const QString &  newName 
)
signal

Emitted whenever a symbol has been renamed from oldName to newName.

See also
rampRenamed()
Since
QGIS 3.4

◆ symbolSaved

void QgsStyle::symbolSaved ( const QString &  name,
QgsSymbol symbol 
)
signal

Emitted every time a new symbol has been added to the database.

Emitted whenever a symbol has been added to the style and the database has been updated as a result.

See also
symbolRemoved()
rampAdded()
symbolChanged()

◆ symbolsOfFavorite()

QStringList QgsStyle::symbolsOfFavorite ( StyleEntity  type) const

Returns the symbol names which are flagged as favorite.

Parameters
typeis either SymbolEntity or ColorampEntity
Returns
A QStringList of the symbol or colorramp names flagged as favorite

Definition at line 1333 of file qgsstyle.cpp.

◆ symbolsOfSmartgroup()

QStringList QgsStyle::symbolsOfSmartgroup ( StyleEntity  type,
int  id 
)

Returns the symbols for the smartgroup.

Definition at line 2404 of file qgsstyle.cpp.

◆ symbolsWithTag()

QStringList QgsStyle::symbolsWithTag ( StyleEntity  type,
int  tagid 
) const

Returns the symbol names with which have the given tag.

Parameters
typeis either SymbolEntity or ColorampEntity
tagidis id of the tag which has been applied over the symbol as int
Returns
A QStringList of the symbol or colorramp names for the given tag id

Definition at line 1367 of file qgsstyle.cpp.

◆ tag()

QString QgsStyle::tag ( int  id) const

Returns the tag name for the given id.

Definition at line 2072 of file qgsstyle.cpp.

◆ tagId()

int QgsStyle::tagId ( const QString &  tag)

Returns the database id for the given tag name.

Definition at line 2260 of file qgsstyle.cpp.

◆ tags()

QStringList QgsStyle::tags ( ) const

Returns a list of all tags in the style database.

See also
addTag()

Definition at line 1433 of file qgsstyle.cpp.

◆ tagsOfSymbol()

QStringList QgsStyle::tagsOfSymbol ( StyleEntity  type,
const QString &  symbol 
)

Returns the tags associated with the symbol.

Parameters
typeis either SymbolEntity or ColorrampEntity
symbolis the name of the symbol or color ramp
Returns
A QStringList of the tags that have been applied to that symbol/colorramp

Definition at line 1943 of file qgsstyle.cpp.

◆ tagSymbol()

bool QgsStyle::tagSymbol ( StyleEntity  type,
const QString &  symbol,
const QStringList &  tags 
)

Tags the symbol with the tags in the list.

Applies the given tags to the given symbol or colorramp

Parameters
typeis either SymbolEntity or ColorrampEntity
symbolis the name of the symbol or colorramp as QString
tagsis the list of the tags that are to be applied as QStringList
Returns
returns the success state of the operation

Definition at line 1787 of file qgsstyle.cpp.

◆ textFormat()

QgsTextFormat QgsStyle::textFormat ( const QString &  name) const

Returns the text format with the specified name.

Since
QGIS 3.10

Definition at line 2152 of file qgsstyle.cpp.

◆ textFormatAdded

void QgsStyle::textFormatAdded ( const QString &  name)
signal

Emitted whenever a text format has been added to the style and the database has been updated as a result.

See also
textFormatRemoved()
symbolSaved()
Since
QGIS 3.10

◆ textFormatChanged

void QgsStyle::textFormatChanged ( const QString &  name)
signal

Emitted whenever a text format's definition is changed.

This does not include name or tag changes.

See also
textFormatAdded()
Since
QGIS 3.10

◆ textFormatCount()

int QgsStyle::textFormatCount ( ) const

Returns count of text formats in the style.

Since
QGIS 3.10

Definition at line 2157 of file qgsstyle.cpp.

◆ textFormatId()

int QgsStyle::textFormatId ( const QString &  name)

Returns the ID in the style database for the given text format by name.

Returns 0 if the text format was not found.

Since
QGIS 3.10

Definition at line 2167 of file qgsstyle.cpp.

◆ textFormatNames()

QStringList QgsStyle::textFormatNames ( ) const

Returns a list of names of text formats in the style.

Since
QGIS 3.10

Definition at line 2162 of file qgsstyle.cpp.

◆ textFormatRemoved

void QgsStyle::textFormatRemoved ( const QString &  name)
signal

Emitted whenever a text format has been removed from the style and the database has been updated as a result.

See also
textFormatAdded()
symbolRemoved()
Since
QGIS 3.10

◆ textFormatRenamed

void QgsStyle::textFormatRenamed ( const QString &  oldName,
const QString &  newName 
)
signal

Emitted whenever a text format has been renamed from oldName to newName.

See also
symbolRenamed()
Since
QGIS 3.10

◆ triggerIconRebuild

void QgsStyle::triggerIconRebuild ( )
slot

Triggers emission of the rebuildIconPreviews() signal.

Note
Not available in Python bindings.
Since
QGIS 3.26

Definition at line 3087 of file qgsstyle.cpp.

Friends And Related Symbol Documentation

◆ Qgs3D

friend class Qgs3D
friend

Definition at line 1311 of file qgsstyle.h.

◆ TestStyle

friend class TestStyle
friend

Definition at line 1312 of file qgsstyle.h.


The documentation for this class was generated from the following files: