Class: QgsAbstractSymbolConverter¶
An abstract base class for converting between QgsSymbol
objects and QVariant representations.
This interface provides a standard mechanism for serializing QGIS
symbols to a generic data container (based on QVariant) and
deserializing them back into native QgsSymbol objects.
Concrete implementations of this class are intended to handle specific external styling formats, such as SLD (Styled Layer Descriptor) or Mapbox GL styles.
Added in version 4.2.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: capabilities(), createSymbol(), formatName(), name(), toVariant()
List of all members, including inherited members
Abstract Methods
Returns the capabilities of the converter. |
|
Creates a new |
|
Returns a translated, user-friendly name for the converter's data format. |
|
Returns the unique name for the converter. |
|
Converts a symbol into a QVariant representation. |
- class qgis.core.QgsAbstractSymbolConverter[source]¶
Bases:
object- abstract capabilities(self) Qgis.SymbolConverterCapability[source]¶
Returns the capabilities of the converter.
- Return type:
- abstract createSymbol(self, variant: Any, context: QgsSymbolConverterContext) QgsSymbol | None¶
Creates a new
QgsSymbolfrom a QVariant representation.- Parameters:
variant (Any) – The QVariant containing the serialized symbol data.
context (QgsSymbolConverterContext) – conversion context
- Return type:
- Returns:
A new
QgsSymbolinstance representing the data in the variant. The caller takes ownership of the returned object. ReturnsNoneif the variant cannot be converted or parsed.- Raises:
QgsNotSupportedException – if the converter does not support deserialization of symbols.
- abstract formatName(self) str[source]¶
Returns a translated, user-friendly name for the converter’s data format.
E.g. “Styled Layer Descriptor (SLD)” for a converter which handles the SLD format.
See also
- Return type:
str
- abstract name(self) str[source]¶
Returns the unique name for the converter.
This should be an untranslated string identifying the converter.
See also
- Return type:
str
- abstract toVariant(self, symbol: QgsSymbol | None, context: QgsSymbolConverterContext) Any[source]¶
Converts a
symbolinto a QVariant representation.The resulting QVariant may be a dictionary (QVariantMap), a JSON string, an XML representation of the symbol, or some binary QByteArray value, depending on the concrete implementation (e.g., SLD vs. Mapbox GL).
Returns an invalid variant if the
symbolcould not be converted, or if serialization of symbols is not supported for this converter.- Raises:
QgsNotSupportedException – if the converter does not support serialization of symbols.
- Parameters:
context (QgsSymbolConverterContext)
- Return type: