QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
Classes | Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
QgsPropertyOverrideButton Class Reference

A button for controlling property overrides which may apply to a widget. More...

#include <qgspropertyoverridebutton.h>

Inheritance diagram for QgsPropertyOverrideButton:
Inheritance graph
[legend]

Public Slots

void setActive (bool active)
 Set whether the current property override definition is to be used. More...
 

Signals

void activated (bool isActive)
 Emitted when the activated status of the widget changes. More...
 
void changed ()
 Emitted when property definition changes. More...
 
void createAuxiliaryField ()
 Emitted when creating a new auxiliary field. More...
 

Public Member Functions

 QgsPropertyOverrideButton (QWidget *parent=nullptr, const QgsVectorLayer *layer=nullptr)
 Constructor for QgsPropertyOverrideButton. More...
 
QString fullDescription () const
 Returns the full definition description and current definition (internally generated on a contextual basis). More...
 
void init (int propertyKey, const QgsAbstractPropertyCollection &collection, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer=nullptr, bool auxiliaryStorageEnabled=false)
 Initialize a newly constructed property button (useful if button was included in a UI layout). More...
 
void init (int propertyKey, const QgsProperty &property, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer=nullptr, bool auxiliaryStorageEnabled=false)
 Initialize a newly constructed property button (useful if button was included in a UI layout). More...
 
void init (int propertyKey, const QgsProperty &property, const QgsPropertyDefinition &definition, const QgsVectorLayer *layer=nullptr, bool auxiliaryStorageEnabled=false)
 Initialize a newly constructed property button (useful if button was included in a UI layout). More...
 
bool isActive () const
 Returns true if the button has an active property. More...
 
int propertyKey () const
 Returns the property key linked to the button. More...
 
void registerCheckedWidget (QWidget *widget, bool natural=true)
 Register a sibling widget that gets checked when the property is active. More...
 
void registerEnabledWidget (QWidget *widget, bool natural=true)
 Register a sibling widget that gets enabled when the property is active, and disabled when the property is inactive. More...
 
void registerExpressionContextGenerator (QgsExpressionContextGenerator *generator)
 Register an expression context generator class that will be used to retrieve an expression context for the button when required. More...
 
void registerExpressionWidget (QWidget *widget)
 Register a sibling widget (line edit, text edit) that will receive the property as an expression. More...
 
void registerLinkedWidget (QWidget *widget)
 Registers a widget which is linked to this button. More...
 
void registerVisibleWidget (QWidget *widget, bool natural=true)
 Register a sibling widget that gets visible when the property is active, and hidden when the property is inactive. More...
 
void setSymbol (std::shared_ptr< QgsSymbol > symbol)
 Sets a symbol which can be used for previews inside the widget or in any dialog created by the widget. More...
 
void setToProperty (const QgsProperty &property)
 Sets the widget to reflect the current state of a QgsProperty. More...
 
void setUsageInfo (const QString &info)
 Set the usage information for the property. More...
 
void setVectorLayer (const QgsVectorLayer *layer)
 Sets the vector layer associated with the button. More...
 
QgsProperty toProperty () const
 Returns a QgsProperty object encapsulating the current state of the widget. More...
 
void updateFieldLists ()
 Updates list of fields. More...
 
QString usageInfo () const
 Returns usage information for the property. More...
 
QgsPropertyDefinition::DataType validDataType () const
 Returns the data type which the widget will accept. More...
 
const QgsVectorLayervectorLayer () const
 Returns the vector layer associated with the button. More...
 

Protected Member Functions

void mouseReleaseEvent (QMouseEvent *event) override
 

Properties

bool active
 
QString usageInfo
 

Detailed Description

A button for controlling property overrides which may apply to a widget.

QgsPropertyOverrideButton is designed to be used alongside the QGIS properties framework (QgsProperty, QgsPropertyDefinition and QgsPropertyCollection).

It allows users to specify field or expression based overrides which should be applied to a property of an object. Eg, this widget is used for controlling data defined overrides in symbology, labeling and layouts.

Since
QGIS 3.0

Definition at line 50 of file qgspropertyoverridebutton.h.

Constructor & Destructor Documentation

◆ QgsPropertyOverrideButton()

QgsPropertyOverrideButton::QgsPropertyOverrideButton ( QWidget *  parent = nullptr,
const QgsVectorLayer layer = nullptr 
)

Constructor for QgsPropertyOverrideButton.

Parameters
parentparent widget
layerassociated vector layer

Definition at line 37 of file qgspropertyoverridebutton.cpp.

Member Function Documentation

◆ activated

void QgsPropertyOverrideButton::activated ( bool  isActive)
signal

Emitted when the activated status of the widget changes.

◆ changed

void QgsPropertyOverrideButton::changed ( )
signal

Emitted when property definition changes.

◆ createAuxiliaryField

void QgsPropertyOverrideButton::createAuxiliaryField ( )
signal

Emitted when creating a new auxiliary field.

◆ fullDescription()

QString QgsPropertyOverrideButton::fullDescription ( ) const
inline

Returns the full definition description and current definition (internally generated on a contextual basis).

Definition at line 141 of file qgspropertyoverridebutton.h.

◆ init() [1/3]

void QgsPropertyOverrideButton::init ( int  propertyKey,
const QgsAbstractPropertyCollection collection,
const QgsPropertiesDefinition definitions,
const QgsVectorLayer layer = nullptr,
bool  auxiliaryStorageEnabled = false 
)

Initialize a newly constructed property button (useful if button was included in a UI layout).

Parameters
propertyKeykey for corresponding property
collectionassociated property collection
definitionsproperties definitions for collection
layerassociated vector layer
auxiliaryStorageEnabledIf true, activate the button to store data defined in auxiliary storage

Definition at line 146 of file qgspropertyoverridebutton.cpp.

◆ init() [2/3]

void QgsPropertyOverrideButton::init ( int  propertyKey,
const QgsProperty property,
const QgsPropertiesDefinition definitions,
const QgsVectorLayer layer = nullptr,
bool  auxiliaryStorageEnabled = false 
)

Initialize a newly constructed property button (useful if button was included in a UI layout).

Parameters
propertyKeykey for corresponding property
propertyinitial value of associated property to show in widget
definitionsproperties definitions for corresponding collection
layerassociated vector layer
auxiliaryStorageEnabledIf true, activate the button to store data defined in auxiliary storage

Definition at line 96 of file qgspropertyoverridebutton.cpp.

◆ init() [3/3]

void QgsPropertyOverrideButton::init ( int  propertyKey,
const QgsProperty property,
const QgsPropertyDefinition definition,
const QgsVectorLayer layer = nullptr,
bool  auxiliaryStorageEnabled = false 
)

Initialize a newly constructed property button (useful if button was included in a UI layout).

Parameters
propertyKeykey for corresponding property
propertyinitial value of associated property to show in widget
definitionproperties definition for button
layerassociated vector layer
auxiliaryStorageEnabledIf true, activate the button to store data defined in auxiliary storage

Definition at line 101 of file qgspropertyoverridebutton.cpp.

◆ isActive()

bool QgsPropertyOverrideButton::isActive ( ) const
inline

Returns true if the button has an active property.

Definition at line 128 of file qgspropertyoverridebutton.h.

◆ mouseReleaseEvent()

void QgsPropertyOverrideButton::mouseReleaseEvent ( QMouseEvent *  event)
overrideprotected

Definition at line 253 of file qgspropertyoverridebutton.cpp.

◆ propertyKey()

int QgsPropertyOverrideButton::propertyKey ( ) const
inline

Returns the property key linked to the button.

Definition at line 123 of file qgspropertyoverridebutton.h.

◆ registerCheckedWidget()

void QgsPropertyOverrideButton::registerCheckedWidget ( QWidget *  widget,
bool  natural = true 
)

Register a sibling widget that gets checked when the property is active.

if natural is false, widget gets unchecked when the property is active.

Note
this should be called after calling init() to be correctly initialized.

Definition at line 204 of file qgspropertyoverridebutton.cpp.

◆ registerEnabledWidget()

void QgsPropertyOverrideButton::registerEnabledWidget ( QWidget *  widget,
bool  natural = true 
)

Register a sibling widget that gets enabled when the property is active, and disabled when the property is inactive.

if natural is false, widget gets disabled when the property is active, and enabled when the property is inactive.

Note
this should be called after calling init() to be correctly initialized.

Definition at line 216 of file qgspropertyoverridebutton.cpp.

◆ registerExpressionContextGenerator()

void QgsPropertyOverrideButton::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 946 of file qgspropertyoverridebutton.cpp.

◆ registerExpressionWidget()

void QgsPropertyOverrideButton::registerExpressionWidget ( QWidget *  widget)

Register a sibling widget (line edit, text edit) that will receive the property as an expression.

Note
this should be called after calling init() to be correctly initialized.

Definition at line 240 of file qgspropertyoverridebutton.cpp.

◆ registerLinkedWidget()

void QgsPropertyOverrideButton::registerLinkedWidget ( QWidget *  widget)

Registers a widget which is linked to this button.

The meaning of linked widgets depends on the property type, and the type of linked widget.

For color properties, linking a QgsColorButton allows the color button to correctly reflect the status of the property when it's set to follow a project color.

Since
QGIS 3.6

Definition at line 951 of file qgspropertyoverridebutton.cpp.

◆ registerVisibleWidget()

void QgsPropertyOverrideButton::registerVisibleWidget ( QWidget *  widget,
bool  natural = true 
)

Register a sibling widget that gets visible when the property is active, and hidden when the property is inactive.

if natural is false, widget gets hidden when the property is active, and visible when the property is inactive.

Note
this should be called after calling init() to be correctly initialized.

Definition at line 228 of file qgspropertyoverridebutton.cpp.

◆ setActive

void QgsPropertyOverrideButton::setActive ( bool  active)
slot

Set whether the current property override definition is to be used.

Definition at line 935 of file qgspropertyoverridebutton.cpp.

◆ setSymbol()

void QgsPropertyOverrideButton::setSymbol ( std::shared_ptr< QgsSymbol symbol)
inline

Sets a symbol which can be used for previews inside the widget or in any dialog created by the widget.

If not specified, a default created symbol will be used instead.

Note
not available in Python bindings

Definition at line 225 of file qgspropertyoverridebutton.h.

◆ setToProperty()

void QgsPropertyOverrideButton::setToProperty ( const QgsProperty property)

Sets the widget to reflect the current state of a QgsProperty.

Definition at line 270 of file qgspropertyoverridebutton.cpp.

◆ setUsageInfo()

void QgsPropertyOverrideButton::setUsageInfo ( const QString &  info)
inline

Set the usage information for the property.

See also
usageInfo()

Definition at line 153 of file qgspropertyoverridebutton.h.

◆ setVectorLayer()

void QgsPropertyOverrideButton::setVectorLayer ( const QgsVectorLayer layer)

Sets the vector layer associated with the button.

This controls which fields are displayed within the widget's pop up menu.

See also
vectorLayer()

Definition at line 197 of file qgspropertyoverridebutton.cpp.

◆ toProperty()

QgsProperty QgsPropertyOverrideButton::toProperty ( ) const

Returns a QgsProperty object encapsulating the current state of the widget.

See also
setToProperty()

Definition at line 192 of file qgspropertyoverridebutton.cpp.

◆ updateFieldLists()

void QgsPropertyOverrideButton::updateFieldLists ( )

Updates list of fields.

Since
QGIS 3.0

Definition at line 152 of file qgspropertyoverridebutton.cpp.

◆ usageInfo()

QString QgsPropertyOverrideButton::usageInfo ( ) const
inline

Returns usage information for the property.

See also
setUsageInfo()

Definition at line 147 of file qgspropertyoverridebutton.h.

◆ validDataType()

QgsPropertyDefinition::DataType QgsPropertyOverrideButton::validDataType ( ) const
inline

Returns the data type which the widget will accept.

This is used to filter out fields from the associated vector layer to only show fields which are compatible with the property.

Definition at line 135 of file qgspropertyoverridebutton.h.

◆ vectorLayer()

const QgsVectorLayer * QgsPropertyOverrideButton::vectorLayer ( ) const
inline

Returns the vector layer associated with the button.

This controls which fields are displayed within the widget's pop up menu.

See also
setVectorLayer()

Definition at line 167 of file qgspropertyoverridebutton.h.

Property Documentation

◆ active

bool QgsPropertyOverrideButton::active
readwrite

Definition at line 50 of file qgspropertyoverridebutton.h.

◆ usageInfo

QString QgsPropertyOverrideButton::usageInfo
readwrite

Definition at line 50 of file qgspropertyoverridebutton.h.


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