QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
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.
 

Signals

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

Public Member Functions

 QgsPropertyOverrideButton (QWidget *parent=nullptr, const QgsVectorLayer *layer=nullptr)
 Constructor for QgsPropertyOverrideButton.
 
QString fullDescription () const
 Returns the full definition description and current definition (internally generated on a contextual basis).
 
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).
 
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).
 
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).
 
bool isActive () const
 Returns true if the button has an active property.
 
int propertyKey () const
 Returns the property key linked to the button.
 
void registerCheckedWidget (QWidget *widget, bool natural=true)
 Register a sibling widget that gets checked when the property is active.
 
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.
 
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 registerExpressionWidget (QWidget *widget)
 Register a sibling widget (line edit, text edit) that will receive the property as an expression.
 
void registerLinkedWidget (QWidget *widget)
 Registers a widget which is linked to this button.
 
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.
 
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.
 
void setToProperty (const QgsProperty &property)
 Sets the widget to reflect the current state of a QgsProperty.
 
void setUsageInfo (const QString &info)
 Set the usage information for the property.
 
void setVectorLayer (const QgsVectorLayer *layer)
 Sets the vector layer associated with the button.
 
QgsProperty toProperty () const
 Returns a QgsProperty object encapsulating the current state of the widget.
 
void updateFieldLists ()
 Updates list of fields.
 
QString usageInfo () const
 Returns usage information for the property.
 
QgsPropertyDefinition::DataType validDataType () const
 Returns the data type which the widget will accept.
 
const QgsVectorLayervectorLayer () const
 Returns the vector layer associated with the button.
 

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.

Definition at line 48 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 38 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 125 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 152 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 102 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 107 of file qgspropertyoverridebutton.cpp.

◆ isActive()

bool QgsPropertyOverrideButton::isActive ( ) const
inline

Returns true if the button has an active property.

Definition at line 112 of file qgspropertyoverridebutton.h.

◆ mouseReleaseEvent()

void QgsPropertyOverrideButton::mouseReleaseEvent ( QMouseEvent *  event)
overrideprotected

Definition at line 259 of file qgspropertyoverridebutton.cpp.

◆ propertyKey()

int QgsPropertyOverrideButton::propertyKey ( ) const
inline

Returns the property key linked to the button.

Definition at line 107 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 210 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 222 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 952 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 246 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 957 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 234 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 941 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 212 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 283 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 137 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 203 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 198 of file qgspropertyoverridebutton.cpp.

◆ updateFieldLists()

void QgsPropertyOverrideButton::updateFieldLists ( )

Updates list of fields.

Definition at line 158 of file qgspropertyoverridebutton.cpp.

◆ usageInfo()

QString QgsPropertyOverrideButton::usageInfo ( ) const
inline

Returns usage information for the property.

See also
setUsageInfo()

Definition at line 131 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 119 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 155 of file qgspropertyoverridebutton.h.

Property Documentation

◆ active

bool QgsPropertyOverrideButton::active
readwrite

Definition at line 52 of file qgspropertyoverridebutton.h.

◆ usageInfo

QString QgsPropertyOverrideButton::usageInfo
readwrite

Definition at line 51 of file qgspropertyoverridebutton.h.


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