QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
QgsSymbolButton Class Reference

A button for creating and modifying QgsSymbol settings. More...

#include <qgssymbolbutton.h>

Inheritance diagram for QgsSymbolButton:
Inheritance graph
[legend]

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 setShowNull (bool showNull)
 Sets whether a set to null (clear) option is shown in the button's drop-down menu.
 
void setSymbol (QgsSymbol *symbol)
 Sets the symbol for the button.
 
void setToDefaultSymbol ()
 Sets symbol to the button's default symbol, if set.
 
void setToNull ()
 Sets symbol to to null.
 

Signals

void changed ()
 Emitted when the symbol's settings are changed.
 

Public Member Functions

 QgsSymbolButton (QWidget *parent=nullptr, const QString &dialogTitle=QString())
 Construct a new symbol button.
 
 ~QgsSymbolButton ()
 
template<class SymbolType >
SymbolType * clonedSymbol ()
 Returns a clone of the current symbol (as the specified template type) defined by the button.
 
const QgsSymboldefaultSymbol () const
 Returns the default symbol for the button, which is shown in the button's drop-down menu for the "default symbol" option.
 
QString dialogTitle () const
 Returns the title for the symbol settings dialog window.
 
bool isNull () const
 Returns true if the current symbol is null.
 
QgsVectorLayerlayer () const
 Returns the layer associated with the widget.
 
QgsMapCanvasmapCanvas () const
 Returns the map canvas associated with the widget.
 
QgsMessageBarmessageBar () const
 Returns the message bar associated with the widget.
 
QSize minimumSizeHint () const override
 
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 setDefaultSymbol (QgsSymbol *symbol)
 Sets the default symbol for the button, which is shown in the button's drop-down menu for the "default symbol" option.
 
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 (Qgis::SymbolType type)
 Sets the symbol type which the button requires.
 
bool showNull () const
 Returns whether the set to null (clear) option is shown in the button's drop-down menu.
 
QSize sizeHint () const override
 
QgsSymbolsymbol ()
 Returns the current symbol defined by the button.
 
Qgis::SymbolType symbolType () const
 Returns the symbol type which the button requires.
 

Protected Member Functions

void changeEvent (QEvent *e) override
 
void dragEnterEvent (QDragEnterEvent *e) override
 
void dragLeaveEvent (QDragLeaveEvent *e) override
 
void dropEvent (QDropEvent *e) override
 
void keyPressEvent (QKeyEvent *e) override
 
void mouseMoveEvent (QMouseEvent *e) override
 
void mousePressEvent (QMouseEvent *e) override
 
void mouseReleaseEvent (QMouseEvent *e) override
 
void resizeEvent (QResizeEvent *event) override
 
void showEvent (QShowEvent *e) override
 
void wheelEvent (QWheelEvent *event) override
 

Properties

QString dialogTitle
 

Detailed Description

A button for creating and modifying QgsSymbol settings.

The button shows a preview icon for the current symbol, and will open a detailed symbol editor dialog (or panel widget) when clicked.

Definition at line 44 of file qgssymbolbutton.h.

Constructor & Destructor Documentation

◆ QgsSymbolButton()

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.

Definition at line 42 of file qgssymbolbutton.cpp.

◆ ~QgsSymbolButton()

QgsSymbolButton::~QgsSymbolButton ( )
default

Member Function Documentation

◆ changed

void QgsSymbolButton::changed ( )
signal

Emitted when the symbol's settings are changed.

See also
symbol()
setSymbol()

◆ changeEvent()

void QgsSymbolButton::changeEvent ( QEvent *  e)
overrideprotected

Definition at line 607 of file qgssymbolbutton.cpp.

◆ clonedSymbol()

template<class SymbolType >
SymbolType * QgsSymbolButton::clonedSymbol ( )
inline

Returns a clone of the current symbol (as the specified template type) defined by the button.

See also
setSymbol()
changed()
Note
Not available in Python bindings.

Definition at line 100 of file qgssymbolbutton.h.

◆ copyColor

void QgsSymbolButton::copyColor ( )
slot

Copies the current symbol color to the clipboard.

See also
pasteColor()

Definition at line 281 of file qgssymbolbutton.cpp.

◆ copySymbol

void QgsSymbolButton::copySymbol ( )
slot

Copies the current symbol to the clipboard.

See also
pasteSymbol()

Definition at line 269 of file qgssymbolbutton.cpp.

◆ defaultSymbol()

const QgsSymbol * QgsSymbolButton::defaultSymbol ( ) const

Returns the default symbol for the button, which is shown in the button's drop-down menu for the "default symbol" option.

Returns
default symbol for the button. Returns nullptr if the default symbol option is disabled.
See also
setDefaultSymbol()
Since
QGIS 3.30

Definition at line 240 of file qgssymbolbutton.cpp.

◆ dialogTitle()

QString QgsSymbolButton::dialogTitle ( ) const

Returns the title for the symbol settings dialog window.

See also
setDialogTitle()

Definition at line 806 of file qgssymbolbutton.cpp.

◆ dragEnterEvent()

void QgsSymbolButton::dragEnterEvent ( QDragEnterEvent *  e)
overrideprotected

Definition at line 378 of file qgssymbolbutton.cpp.

◆ dragLeaveEvent()

void QgsSymbolButton::dragLeaveEvent ( QDragLeaveEvent *  e)
overrideprotected

Definition at line 394 of file qgssymbolbutton.cpp.

◆ dropEvent()

void QgsSymbolButton::dropEvent ( QDropEvent *  e)
overrideprotected

Definition at line 401 of file qgssymbolbutton.cpp.

◆ isNull()

bool QgsSymbolButton::isNull ( ) const

Returns true if the current symbol is null.

See also
setShowNull()
showNull()
Since
QGIS 3.26

Definition at line 826 of file qgssymbolbutton.cpp.

◆ keyPressEvent()

void QgsSymbolButton::keyPressEvent ( QKeyEvent *  e)
overrideprotected

Definition at line 365 of file qgssymbolbutton.cpp.

◆ layer()

QgsVectorLayer * QgsSymbolButton::layer ( ) const

Returns the layer associated with the widget.

See also
setLayer()

Definition at line 220 of file qgssymbolbutton.cpp.

◆ mapCanvas()

QgsMapCanvas * QgsSymbolButton::mapCanvas ( ) const

Returns the map canvas associated with the widget.

See also
setMapCanvas()

Definition at line 200 of file qgssymbolbutton.cpp.

◆ messageBar()

QgsMessageBar * QgsSymbolButton::messageBar ( ) const

Returns the message bar associated with the widget.

See also
setMessageBar()
Since
QGIS 3.6

Definition at line 215 of file qgssymbolbutton.cpp.

◆ minimumSizeHint()

QSize QgsSymbolButton::minimumSizeHint ( ) const
override

Definition at line 96 of file qgssymbolbutton.cpp.

◆ mouseMoveEvent()

void QgsSymbolButton::mouseMoveEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 319 of file qgssymbolbutton.cpp.

◆ mousePressEvent()

void QgsSymbolButton::mousePressEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 298 of file qgssymbolbutton.cpp.

◆ mouseReleaseEvent()

void QgsSymbolButton::mouseReleaseEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 352 of file qgssymbolbutton.cpp.

◆ pasteColor

void QgsSymbolButton::pasteColor ( )
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.

See also
copyColor()

Definition at line 286 of file qgssymbolbutton.cpp.

◆ pasteSymbol

void QgsSymbolButton::pasteSymbol ( )
slot

Pastes a symbol from the clipboard.

If clipboard does not contain a valid symbol then no change is applied.

See also
copySymbol()

Definition at line 274 of file qgssymbolbutton.cpp.

◆ registerExpressionContextGenerator()

void QgsSymbolButton::registerExpressionContextGenerator ( QgsExpressionContextGenerator generator)

Register an expression context generator class that will be used to retrieve an expression context for the button when required.

Definition at line 230 of file qgssymbolbutton.cpp.

◆ resizeEvent()

void QgsSymbolButton::resizeEvent ( QResizeEvent *  event)
overrideprotected

Definition at line 622 of file qgssymbolbutton.cpp.

◆ setColor

void QgsSymbolButton::setColor ( const QColor &  color)
slot

Sets the current color for the symbol.

Will emit a changed() signal if the color is different to the previous symbol color.

Definition at line 253 of file qgssymbolbutton.cpp.

◆ setDefaultSymbol()

void QgsSymbolButton::setDefaultSymbol ( QgsSymbol symbol)

Sets the default symbol for the button, which is shown in the button's drop-down menu for the "default symbol" option.

Parameters
symboldefault symbol for the button. Set to nullptr to disable the default symbol option. Ownership of symbol is transferred to the button.
See also
defaultSymbol()
Since
QGIS 3.30

Definition at line 235 of file qgssymbolbutton.cpp.

◆ setDialogTitle()

void QgsSymbolButton::setDialogTitle ( const QString &  title)

Sets the title for the symbol settings dialog window.

See also
dialogTitle()

Definition at line 801 of file qgssymbolbutton.cpp.

◆ setLayer()

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.

See also
layer()

Definition at line 225 of file qgssymbolbutton.cpp.

◆ setMapCanvas()

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.

See also
mapCanvas()

Definition at line 205 of file qgssymbolbutton.cpp.

◆ setMessageBar()

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.

See also
messageBar()
Since
QGIS 3.6

Definition at line 210 of file qgssymbolbutton.cpp.

◆ setShowNull

void QgsSymbolButton::setShowNull ( bool  showNull)
slot

Sets whether a set to null (clear) option is shown in the button's drop-down menu.

Parameters
showNullset to true to show a null option
See also
showNull()
isNull()
Since
QGIS 3.26

Definition at line 816 of file qgssymbolbutton.cpp.

◆ setSymbol

void QgsSymbolButton::setSymbol ( QgsSymbol symbol)
slot

Sets the symbol for the button.

Ownership of symbol is transferred to the button.

See also
symbol()
changed()

Definition at line 245 of file qgssymbolbutton.cpp.

◆ setSymbolType()

void QgsSymbolButton::setSymbolType ( Qgis::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.

See also
symbolType()

Definition at line 106 of file qgssymbolbutton.cpp.

◆ setToDefaultSymbol

void QgsSymbolButton::setToDefaultSymbol ( )
slot

Sets symbol to the button's default symbol, if set.

See also
setDefaultSymbol()
defaultSymbol()
setToNull()
Since
QGIS 3.30

Definition at line 836 of file qgssymbolbutton.cpp.

◆ setToNull

void QgsSymbolButton::setToNull ( )
slot

Sets symbol to to null.

See also
setShowNull()
setToDefaultSymbol()
showNull()
Since
QGIS 3.26

Definition at line 831 of file qgssymbolbutton.cpp.

◆ showEvent()

void QgsSymbolButton::showEvent ( QShowEvent *  e)
overrideprotected

Definition at line 616 of file qgssymbolbutton.cpp.

◆ showNull()

bool QgsSymbolButton::showNull ( ) const

Returns whether the set to null (clear) option is shown in the button's drop-down menu.

See also
setShowNull()
isNull()
Since
QGIS 3.26

Definition at line 821 of file qgssymbolbutton.cpp.

◆ sizeHint()

QSize QgsSymbolButton::sizeHint ( ) const
override

Definition at line 101 of file qgssymbolbutton.cpp.

◆ symbol()

QgsSymbol * QgsSymbolButton::symbol ( )

Returns the current symbol defined by the button.

See also
setSymbol()
changed()

Definition at line 811 of file qgssymbolbutton.cpp.

◆ symbolType()

Qgis::SymbolType QgsSymbolButton::symbolType ( ) const
inline

Returns the symbol type which the button requires.

See also
setSymbolType()

Definition at line 73 of file qgssymbolbutton.h.

◆ wheelEvent()

void QgsSymbolButton::wheelEvent ( QWheelEvent *  event)
overrideprotected

Definition at line 419 of file qgssymbolbutton.cpp.

Property Documentation

◆ dialogTitle

QString QgsSymbolButton::dialogTitle
readwrite

Definition at line 48 of file qgssymbolbutton.h.


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