Class: QgsRendererCategory¶
Represents an individual category (class) from a
QgsCategorizedSymbolRenderer
.
Methods
Returns a string representing the categories settings, used for debugging purposes only. |
|
Returns the label for this category, which is used to represent the category within legends and the layer tree. |
|
Returns |
|
Sets the label for this category, which is used to represent the category within legends and the layer tree. |
|
Sets whether the category is currently enabled and should be rendered. |
|
Sets the symbol which will be used to render this category. |
|
Sets the value corresponding to this category. |
|
Returns the symbol which will be used to render this category. |
|
Converts the category to a matching SLD rule, within the specified DOM document and element. |
|
Returns the unique identifier for this category. |
|
Returns the value corresponding to this category. |
- class qgis.core.QgsRendererCategory[source]¶
Bases:
object
- __init__()
- __init__(value: Any, symbol: QgsSymbol | None, label: str | None, render: bool = True, uuid: str | None = '')
Constructor for a new QgsRendererCategory, with the specified
value
andsymbol
.If
value
is a list, then the category will match any of the values from this list.The ownership of
symbol
is transferred to the category.The
label
argument specifies the label used for this category in legends and the layer tree.The
render
argument indicates whether the category should initially be rendered and appear checked in the layer tree.The optional
uuid
argument manually set the UUID key identifier for the category (since QGIS 3.34).- Parameters:
value (Any)
symbol (Optional[QgsSymbol])
label (Optional[str])
render (bool = True)
uuid (Optional[str] = '')
- __init__(cat: QgsRendererCategory)
- Parameters:
cat (QgsRendererCategory)
- dump(self) str [source]¶
Returns a string representing the categories settings, used for debugging purposes only.
- Return type:
str
- label(self) str [source]¶
Returns the label for this category, which is used to represent the category within legends and the layer tree.
See also
- Return type:
str
- renderState(self) bool [source]¶
Returns
True
if the category is currently enabled and should be rendered.See also
- Return type:
bool
- setLabel(self, label: str | None)[source]¶
Sets the
label
for this category, which is used to represent the category within legends and the layer tree.See also
- Parameters:
label (Optional[str])
- setRenderState(self, render: bool)[source]¶
Sets whether the category is currently enabled and should be rendered.
See also
- Parameters:
render (bool)
- setSymbol(self, s: QgsSymbol | None)[source]¶
Sets the symbol which will be used to render this category.
Ownership of the symbol is transferred to the category.
See also
- Parameters:
s (Optional[QgsSymbol])
- setValue(self, value: Any)[source]¶
Sets the
value
corresponding to this category.If
value
is a list, then the category will match any of the values from this list.See also
- Parameters:
value (Any)
- symbol(self) QgsSymbol | None [source]¶
Returns the symbol which will be used to render this category.
See also
- Return type:
Optional[QgsSymbol]
- toSld(self, doc: QDomDocument, element: QDomElement, props: Dict[str, Any])[source]¶
Converts the category to a matching SLD rule, within the specified DOM document and
element
.Deprecated since version 3.44: Use the version with
QgsSldExportContext
instead.- Parameters:
doc (QDomDocument)
element (QDomElement)
props (Dict[str, Any])
- toSld(self, doc: QDomDocument, element: QDomElement, classAttribute: str | None, context: QgsSldExportContext) bool [source]
Converts the category to a matching SLD rule, within the specified DOM document and
element
.Added in version 3.44.
- Parameters:
doc (QDomDocument)
element (QDomElement)
classAttribute (Optional[str])
context (
QgsSldExportContext
)
- Return type:
bool
- uuid(self) str [source]¶
Returns the unique identifier for this category.
Added in version 3.34.
- Return type:
str