Class: QgsProjectStyleSettings¶
Contains settings and properties relating to how a
QgsProject
should handle styling.
Added in version 3.26.
Class Hierarchy¶
Base classes¶
Methods
Adds a style database path to the project. |
|
Returns the project's color model |
|
Returns the project's color space. |
|
Returns the combined style model which includes all style databases associated with the project. |
|
Returns the project default color ramp. |
|
Returns the project default symbol for a given type. |
|
Returns the default symbol opacity. |
|
Returns the project default text format. |
|
Returns the style database to use for project specific styles. |
|
Returns whether the default symbol fill color is randomized. |
|
Reads the settings's state from a DOM element. |
|
Removes and deletes the project style database. |
|
Resets the settings to a default state. |
|
Set the project's color model to colorModel |
|
Set the project's current color space to colorSpace. |
|
Sets the project default color ramp. |
|
Sets the project default symbol for a given type. |
|
Sets the default symbol opacity. |
|
Sets the project default text format. |
|
Sets the style database to use for the project style. |
|
Sets whether the default symbol fill color is randomized. |
|
Sets the paths to all style databases associated with the project. |
|
Returns a reference to the style database associated with the project with matching file path. |
|
Returns a list of all style databases (file paths) associated with the project. |
|
Returns a list of all the styles associated with the project. |
|
Returns a DOM element representing the settings. |
Signals
Emitted whenever the set of style databases associated with the project is changed. |
- class qgis.core.QgsProjectStyleSettings[source]¶
Bases:
QObject
- __init__(project: QgsProject | None = None)
Constructor for QgsProjectStyleSettings for the specified
project
.Ownership is transferred to the
project
.- Parameters:
project (Optional[QgsProject] = None)
- addStyleDatabasePath(self, path: str | None)[source]¶
Adds a style database
path
to the project.Paths can be either style .db databases, or .xml exports of style databases.
The file path added by this method must always be absolute paths. Depending on the project settings, they may be converted to relative paths when the project is saved.
See also
See also
See also
- Parameters:
path (Optional[str])
- colorModel(self) Qgis.ColorModel [source]¶
Returns the project’s color model
This model is used as the default color model when selecting a color in the whole application. Any color defined in a different color model than the returned model will be converted to this color model when exporting a layout.
The color model defaults to
Qgis
.ColorModel.RgbSee also
Added in version 3.40.
- Return type:
- colorSpace(self) QColorSpace [source]¶
Returns the project’s color space.
The project color’s space will be added to PDF layout exports when it is defined (i.e. it is different from the default invalid QColorSpace).
The color space defaults to an invalid color space.
See also
Added in version 3.40.
- Return type:
QColorSpace
- combinedStyleModel(self) QgsCombinedStyleModel | None [source]¶
Returns the combined style model which includes all style databases associated with the project.
This model also includes
QgsStyle.defaultStyle()
.Note
This is only available on builds based on Qt 5.13 or later.
See also
- Return type:
Optional[QgsCombinedStyleModel]
- defaultColorRamp(self) QgsColorRamp | None [source]¶
Returns the project default color ramp.
- Return type:
Optional[QgsColorRamp]
- Returns:
a color ramp pointer or
None
if there is no default set
Note
the color ramp ownership is transferred to the caller
- defaultSymbol(self, symbolType: Qgis.SymbolType) QgsSymbol | None [source]¶
Returns the project default symbol for a given type.
- Parameters:
symbolType (Qgis.SymbolType) – the symbol type
- Return type:
Optional[QgsSymbol]
- Returns:
a symbol pointer or
None
if there is no default set
Note
the symbol ownership is transferred to the caller
- defaultTextFormat(self) QgsTextFormat [source]¶
Returns the project default text format.
Note
if no default is defined, the returned format will be invalid
- Return type:
- projectStyle(self) QgsStyle | None [source]¶
Returns the style database to use for project specific styles.
See also
- Return type:
Optional[QgsStyle]
- randomizeDefaultSymbolColor(self) bool [source]¶
Returns whether the default symbol fill color is randomized.
- Return type:
bool
- readXml(self, element: QDomElement, context: QgsReadWriteContext, flags: Qgis.ProjectReadFlags | Qgis.ProjectReadFlag = Qgis.ProjectReadFlags()) bool [source]¶
Reads the settings’s state from a DOM element.
See also
- Parameters:
element (QDomElement)
context (QgsReadWriteContext)
flags (Union[Qgis.ProjectReadFlags, Qgis.ProjectReadFlag] = Qgis.ProjectReadFlags())
- Return type:
bool
- removeProjectStyle(self)[source]¶
Removes and deletes the project style database.
Added in version 3.32.
- setColorModel(self, colorModel: Qgis.ColorModel)[source]¶
Set the project’s color model to
colorModel
This sets the default color model used when selecting a color in the whole application. Any color defined in a different color model than the one specified here will be converted to this color model when exporting a layout.
If a color space has already been set and its color model differs from
colorModel
, the project color space will be reset to invalid one (This is only true if QGIS is built against Qt 6.8.0 or greater).setColorSpace()
colorSpace()The color model defaults to
Qgis
.ColorModel.RgbSee also
Added in version 3.40.
- Parameters:
colorModel (Qgis.ColorModel)
- setColorSpace(self, colorSpace: QColorSpace)[source]¶
Set the project’s current color space to
colorSpace
.colorSpace
must be a valid RGB or CMYK color space. The color space’s ICC profile will be added as a project attached file.The project color’s space will be added to PDF layout exports when it is defined (i.e. it is different from the default invalid QColorSpace).
If a color model has already been set and it differs from
colorSpace
’s color model, the project’s color model is set to match the color space’s color model (This is only true if QGIS is built against Qt 6.8.0 or greater).setColorModel()
colorModel()The color space defaults to an invalid color space.
See also
Added in version 3.40.
- Parameters:
colorSpace (QColorSpace)
- setDefaultColorRamp(self, colorRamp: QgsColorRamp | None)[source]¶
Sets the project default color ramp.
- Parameters:
colorRamp (Optional[QgsColorRamp]) – the color ramp, set to
None
to clear default
Note
the color ramp ownership is not transferred
- setDefaultSymbol(self, symbolType: Qgis.SymbolType, symbol: QgsSymbol | None)[source]¶
Sets the project default symbol for a given type.
- Parameters:
symbolType (Qgis.SymbolType) – the symbol type
symbol (Optional[QgsSymbol]) – the symbol pointer, set to
None
to clear default
Note
the symbol ownership is not transferred
- setDefaultSymbolOpacity(self, opacity: float)[source]¶
Sets the default symbol opacity.
- Parameters:
opacity (float)
- setDefaultTextFormat(self, textFormat: QgsTextFormat)[source]¶
Sets the project default text format.
- Parameters:
textFormat (QgsTextFormat) – the text format, an invalid format is interpreted as no default
- setProjectStyle(self, style: QgsStyle | None)[source]¶
Sets the style database to use for the project style.
See also
- Parameters:
style (Optional[QgsStyle])
- setRandomizeDefaultSymbolColor(self, randomized: bool)[source]¶
Sets whether the default symbol fill color is randomized.
- Parameters:
randomized (bool)
- setStyleDatabasePaths(self, paths: Iterable[str | None])[source]¶
Sets the
paths
to all style databases associated with the project.Paths can be either style .db databases, or .xml exports of style databases.
The file paths set by this method must always be absolute paths. Depending on the project settings, they may be converted to relative paths when the project is saved.
See also
See also
See also
- Parameters:
paths (Iterable[Optional[str]])
- styleAtPath(self, path: str | None) QgsStyle | None [source]¶
Returns a reference to the style database associated with the project with matching file
path
.- Parameters:
path (Optional[str])
- Return type:
Optional[QgsStyle]
- styleDatabasePaths(self) List[str] [source]¶
Returns a list of all style databases (file paths) associated with the project.
The file paths returned by this method will always be absolute paths. Depending on the project settings, they may be converted to relative paths when the project is saved.
See also
See also
See also
- Return type:
List[str]
- signal styleDatabasesChanged[source]¶
Emitted whenever the set of style databases associated with the project is changed.
- styles(self) List[QgsStyle] ¶
Returns a list of all the styles associated with the project.
See also
- Return type:
List[QgsStyle]
- writeXml(self, doc: QDomDocument, context: QgsReadWriteContext) QDomElement [source]¶
Returns a DOM element representing the settings.
See also
- Parameters:
doc (QDomDocument)
context (QgsReadWriteContext)
- Return type:
QDomElement