QgsSymbolButton class
A button for creating and modifying QgsSymbol settings.
Contents
The button shows a preview icon for the current symbol, and will open a detailed symbol editor dialog (or panel widget) when clicked.
Constructors, destructors, conversion operators
- QgsSymbolButton(QWidget* parent = nullptr, const QString& dialogTitle = QString())
- Construct a new symbol button.
Public functions
-
template<class SymbolType>auto clonedSymbol() -> SymbolType*
- Returns a clone of the current symbol (as the specified template type) defined by the button.
- auto dialogTitle() const -> QString
- Returns the title for the symbol settings dialog window.
- auto layer() const -> QgsVectorLayer*
- Returns the layer associated with the widget.
- auto mapCanvas() const -> QgsMapCanvas*
- Returns the map canvas associated with the widget.
- auto messageBar() const -> QgsMessageBar*
- Returns the message bar associated with the widget.
- void registerExpressionContextGenerator(QgsExpressionContextGenerator* generator)
- Register an expression context generator class that will be used to retrieve an expression context for the button when required.
- void setDialogTitle(const QString& title)
- Sets the title for the symbol settings dialog window.
- void setLayer(QgsVectorLayer* layer)
- Sets a layer to associate with the widget.
- void setMapCanvas(QgsMapCanvas* canvas)
- Sets a map canvas to associate with the widget.
- void setMessageBar(QgsMessageBar* bar)
- Sets the message bar associated with the widget.
-
void setSymbolType(QgsSymbol::
SymbolType type) - Sets the symbol type which the button requires.
- auto symbol() -> QgsSymbol*
- Returns the current symbol defined by the button.
-
auto symbolType() const -> QgsSymbol::
SymbolType - Returns the symbol type which the button requires.
Signals
- void changed()
- Emitted when the symbol's settings are changed.
Public slots
- void copyColor()
- Copies the current symbol color to the clipboard.
- void copySymbol()
- Copies the current symbol to the clipboard.
- void pasteColor()
- Pastes a color from the clipboard to the symbol.
- void pasteSymbol()
- Pastes a symbol from the clipboard.
- void setColor(const QColor& color)
- Sets the current color for the symbol.
- void setSymbol(QgsSymbol* symbol)
- Sets the symbol for the button.
Function documentation
QgsSymbolButton:: QgsSymbolButton(QWidget* parent = nullptr,
const QString& dialogTitle = QString())
Construct a new symbol button.
Use dialogTitle string to define the title to show in the symbol settings dialog.
template<class SymbolType>
SymbolType* QgsSymbolButton:: clonedSymbol()
Returns a clone of the current symbol (as the specified template type) defined by the button.
QString QgsSymbolButton:: dialogTitle() const
Returns the title for the symbol settings dialog window.
QgsVectorLayer* QgsSymbolButton:: layer() const
Returns the layer associated with the widget.
QgsMapCanvas* QgsSymbolButton:: mapCanvas() const
Returns the map canvas associated with the widget.
QgsMessageBar* QgsSymbolButton:: messageBar() const
Returns the message bar associated with the widget.
void QgsSymbolButton:: setDialogTitle(const QString& title)
Sets the title for the symbol settings dialog window.
void QgsSymbolButton:: setLayer(QgsVectorLayer* layer)
Sets a layer to associate with the widget.
This allows the widget to setup layer related settings within the symbol settings dialog, such as correctly populating data defined override buttons.
void QgsSymbolButton:: setMapCanvas(QgsMapCanvas* canvas)
Sets a map canvas to associate with the widget.
This allows the widget to fetch current settings from the map canvas, such as current scale.
void QgsSymbolButton:: setMessageBar(QgsMessageBar* bar)
Sets the message bar associated with the widget.
This allows the widget to push feedback messages to the appropriate message bar.
void QgsSymbolButton:: setSymbolType(QgsSymbol:: SymbolType type)
Sets the symbol type which the button requires.
If the type differs from the current symbol type, the symbol will be reset to a default symbol style of the new type.
QgsSymbol:: SymbolType QgsSymbolButton:: symbolType() const
Returns the symbol type which the button requires.
void QgsSymbolButton:: changed() signal
Emitted when the symbol's settings are changed.
void QgsSymbolButton:: copyColor() public slot
Copies the current symbol color to the clipboard.
void QgsSymbolButton:: copySymbol() public slot
Copies the current symbol to the clipboard.
void QgsSymbolButton:: pasteColor() public slot
Pastes a color from the clipboard to the symbol.
If clipboard does not contain a valid color or string representation of a color, then no change is applied.
void QgsSymbolButton:: pasteSymbol() public slot
Pastes a symbol from the clipboard.
If clipboard does not contain a valid symbol then no change is applied.