QGIS API Documentation  3.37.0-Master (a5b4d9743e8)
Public Slots | Signals | Public Member Functions | Protected Types | Protected Slots | Protected Member Functions | Protected Attributes | Properties | List of all members
QgsTextFormatWidget Class Reference

A widget for customizing text formatting settings. More...

#include <qgstextformatwidget.h>

Inheritance diagram for QgsTextFormatWidget:
Inheritance graph
[legend]

Public Slots

void setDockMode (bool enabled)
 Sets whether the widget should be shown in a compact dock mode. More...
 

Signals

void auxiliaryFieldCreated ()
 Emitted when an auxiliary field is created in the widget. More...
 
void widgetChanged ()
 Emitted when the text format defined by the widget changes. More...
 

Public Member Functions

 QgsTextFormatWidget (const QgsTextFormat &format=QgsTextFormat(), QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, QgsMapLayer *layer=nullptr)
 Constructor for QgsTextFormatWidget. More...
 
 ~QgsTextFormatWidget () override
 
QgsSymbolWidgetContext context () const
 Returns the context in which the widget is shown, e.g., the associated map canvas and expression contexts. More...
 
void deactivateField (QgsPalLayerSettings::Property key)
 Deactivate a field from data defined properties and update the corresponding button. More...
 
QgsTextFormat format (bool includeDataDefinedProperties=true) const
 Returns the current formatting settings defined by the widget. More...
 
virtual void setContext (const QgsSymbolWidgetContext &context)
 Sets the context in which the widget is shown, e.g., the associated map canvas and expression contexts. More...
 
void setFormat (const QgsTextFormat &format)
 Sets the current formatting settings. More...
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()=default
 

Protected Types

enum  Mode { Text = 0 , Labeling }
 Widget mode. More...
 

Protected Slots

void populateDataDefinedButtons ()
 Sets up connections required for data defined buttons, or updates the existing definition of these buttons. More...
 
virtual void saveFormat ()
 Saves the current text settings to a style entry. More...
 
virtual void setFormatFromStyle (const QString &name, QgsStyle::StyleEntity type, const QString &stylePath)
 Sets the current text settings from a style entry. More...
 
void updateLinePlacementOptions ()
 Updates line placement options to reflect current state of widget. More...
 
void updatePlacementWidgets ()
 Updates label placement options to reflect current state of widget. More...
 
void updatePreview ()
 Updates the text preview. More...
 

Protected Member Functions

 QgsTextFormatWidget (QgsMapCanvas *mapCanvas, QWidget *parent, Mode mode, QgsMapLayer *layer=nullptr)
 Constructor for QgsTextFormatWidget. More...
 
QgsExpressionContext createExpressionContext () const override
 This method needs to be reimplemented in all classes which implement this interface and return an expression context. More...
 
Q_DECL_DEPRECATED void enableDataDefinedAlignment (bool enable)
 Update the enabled state of the data defined alignment buttons. More...
 
Qgis::GeometryType labelGeometryType () const
 Returns the geometry type which will be used by the labeling engine when registering labels for the labeling settings currently defined by the widget. More...
 
void setPreviewBackground (const QColor &color)
 Sets the background color for the text preview widget. More...
 
void updateWidgetForFormat (const QgsTextFormat &format)
 Updates the widget's state to reflect the settings in a QgsTextFormat. More...
 

Protected Attributes

QgsSymbolWidgetContext mContext
 Context in which widget is shown. More...
 
QgsPropertyCollection mDataDefinedProperties
 Data defined properties as defined in the widget. More...
 
QButtonGroup * mDirectSymbBtnGrp = nullptr
 Symbol direction button group. More...
 
Qgis::GeometryType mGeomType = Qgis::GeometryType::Unknown
 Geometry type for layer, if known. More...
 
QgsMapLayermLayer = nullptr
 Associated vector layer. More...
 
QgsMapCanvasmMapCanvas = nullptr
 Associated map canvas. More...
 
QList< QgsSymbolLayerReferencemMaskedSymbolLayers
 
int mMinPixelLimit = 0
 Pixel size font limit. More...
 
QButtonGroup * mQuadrantBtnGrp = nullptr
 Quadrant button group. More...
 
QgsStringReplacementCollection mSubstitutions
 Text substitution list. More...
 
QButtonGroup * mUpsidedownBtnGrp = nullptr
 Upside down labels button group. More...
 

Properties

QgsTextFormat format
 

Detailed Description

A widget for customizing text formatting settings.

QgsTextFormatWidget provides a widget for controlling the appearance of text rendered using QgsTextRenderer. The widget includes all settings contained within a QgsTextFormat, including shadow, background and buffer.

Additionally, the widget can handle labeling settings due to the large overlap between the text renderer settings and the labeling settings. This mode is possible by subclassing QgsTextFormatWidget and calling the protected constructor with a mode of Labeling.

Definition at line 49 of file qgstextformatwidget.h.

Member Enumeration Documentation

◆ Mode

enum QgsTextFormatWidget::Mode
protected

Widget mode.

Enumerator
Text 

Default mode, show text formatting settings only.

Labeling 

Show labeling settings in addition to text formatting settings.

Definition at line 127 of file qgstextformatwidget.h.

Constructor & Destructor Documentation

◆ QgsTextFormatWidget() [1/2]

QgsTextFormatWidget::QgsTextFormatWidget ( const QgsTextFormat format = QgsTextFormat(),
QgsMapCanvas mapCanvas = nullptr,
QWidget *  parent = nullptr,
QgsMapLayer layer = nullptr 
)

Constructor for QgsTextFormatWidget.

Parameters
formatinitial formatting settings to show in widget
mapCanvasassociated map canvas
parentparent widget
layerassociated layer (vector or mesh)

Definition at line 50 of file qgstextformatwidget.cpp.

◆ ~QgsTextFormatWidget()

QgsTextFormatWidget::~QgsTextFormatWidget ( )
override

Definition at line 1048 of file qgstextformatwidget.cpp.

◆ QgsTextFormatWidget() [2/2]

QgsTextFormatWidget::QgsTextFormatWidget ( QgsMapCanvas mapCanvas,
QWidget *  parent,
Mode  mode,
QgsMapLayer layer = nullptr 
)
protected

Constructor for QgsTextFormatWidget.

Parameters
mapCanvasassociated map canvas
parentparent widget
modewidget mode
layerassociated vector layer

Definition at line 61 of file qgstextformatwidget.cpp.

Member Function Documentation

◆ auxiliaryFieldCreated

void QgsTextFormatWidget::auxiliaryFieldCreated ( )
signal

Emitted when an auxiliary field is created in the widget.

Since
QGIS 3.10

◆ context()

QgsSymbolWidgetContext QgsTextFormatWidget::context ( ) const

Returns the context in which the widget is shown, e.g., the associated map canvas and expression contexts.

See also
setContext()
Since
QGIS 3.10

Definition at line 1196 of file qgstextformatwidget.cpp.

◆ createExpressionContext()

QgsExpressionContext QgsTextFormatWidget::createExpressionContext ( ) const
overrideprotectedvirtual

This method needs to be reimplemented in all classes which implement this interface and return an expression context.

Implements QgsExpressionContextGenerator.

Definition at line 2125 of file qgstextformatwidget.cpp.

◆ deactivateField()

void QgsTextFormatWidget::deactivateField ( QgsPalLayerSettings::Property  key)

Deactivate a field from data defined properties and update the corresponding button.

Parameters
keyThe property key to deactivate

Definition at line 1201 of file qgstextformatwidget.cpp.

◆ enableDataDefinedAlignment()

Q_DECL_DEPRECATED void QgsTextFormatWidget::enableDataDefinedAlignment ( bool  enable)
inlineprotected

Update the enabled state of the data defined alignment buttons.

Deprecated:
QGIS 3.24

Definition at line 159 of file qgstextformatwidget.h.

◆ format()

QgsTextFormat QgsTextFormatWidget::format ( bool  includeDataDefinedProperties = true) const

Returns the current formatting settings defined by the widget.

If includateDataDefinedProperties is true, then data defined properties specified in the widget will be included in the format definition.

Definition at line 1069 of file qgstextformatwidget.cpp.

◆ labelGeometryType()

Qgis::GeometryType QgsTextFormatWidget::labelGeometryType ( ) const
protected

Returns the geometry type which will be used by the labeling engine when registering labels for the labeling settings currently defined by the widget.

Since
QGIS 3.16

Definition at line 2147 of file qgstextformatwidget.cpp.

◆ populateDataDefinedButtons

void QgsTextFormatWidget::populateDataDefinedButtons ( )
protectedslot

Sets up connections required for data defined buttons, or updates the existing definition of these buttons.

Since
QGIS 3.10

Definition at line 718 of file qgstextformatwidget.cpp.

◆ saveFormat

void QgsTextFormatWidget::saveFormat ( )
protectedvirtualslot

Saves the current text settings to a style entry.

Definition at line 1965 of file qgstextformatwidget.cpp.

◆ setContext()

void QgsTextFormatWidget::setContext ( const QgsSymbolWidgetContext context)
virtual

Sets the context in which the widget is shown, e.g., the associated map canvas and expression contexts.

See also
context()
Since
QGIS 3.10

Definition at line 1219 of file qgstextformatwidget.cpp.

◆ setDockMode

void QgsTextFormatWidget::setDockMode ( bool  enabled)
slot

Sets whether the widget should be shown in a compact dock mode.

Parameters
enabledset to true to show in dock mode.

Definition at line 628 of file qgstextformatwidget.cpp.

◆ setFormat()

void QgsTextFormatWidget::setFormat ( const QgsTextFormat format)

Sets the current formatting settings.

Since
QGIS 3.2

Definition at line 1178 of file qgstextformatwidget.cpp.

◆ setFormatFromStyle

void QgsTextFormatWidget::setFormatFromStyle ( const QString &  name,
QgsStyle::StyleEntity  type,
const QString &  stylePath 
)
protectedvirtualslot

Sets the current text settings from a style entry.

Since
QGIS 3.10

Definition at line 1923 of file qgstextformatwidget.cpp.

◆ setPreviewBackground()

void QgsTextFormatWidget::setPreviewBackground ( const QColor &  color)
protected

Sets the background color for the text preview widget.

Parameters
colorbackground color

Definition at line 1320 of file qgstextformatwidget.cpp.

◆ updateLinePlacementOptions

void QgsTextFormatWidget::updateLinePlacementOptions ( )
protectedslot

Updates line placement options to reflect current state of widget.

Definition at line 1715 of file qgstextformatwidget.cpp.

◆ updatePlacementWidgets

void QgsTextFormatWidget::updatePlacementWidgets ( )
protectedslot

Updates label placement options to reflect current state of widget.

Definition at line 1335 of file qgstextformatwidget.cpp.

◆ updatePreview

void QgsTextFormatWidget::updatePreview ( )
protectedslot

Updates the text preview.

Since
QGIS 3.10

Definition at line 1300 of file qgstextformatwidget.cpp.

◆ updateWidgetForFormat()

void QgsTextFormatWidget::updateWidgetForFormat ( const QgsTextFormat format)
protected

Updates the widget's state to reflect the settings in a QgsTextFormat.

Parameters
formatsource format

Definition at line 883 of file qgstextformatwidget.cpp.

◆ widgetChanged

void QgsTextFormatWidget::widgetChanged ( )
signal

Emitted when the text format defined by the widget changes.

Member Data Documentation

◆ mContext

QgsSymbolWidgetContext QgsTextFormatWidget::mContext
protected

Context in which widget is shown.

Definition at line 186 of file qgstextformatwidget.h.

◆ mDataDefinedProperties

QgsPropertyCollection QgsTextFormatWidget::mDataDefinedProperties
protected

Data defined properties as defined in the widget.

Definition at line 189 of file qgstextformatwidget.h.

◆ mDirectSymbBtnGrp

QButtonGroup* QgsTextFormatWidget::mDirectSymbBtnGrp = nullptr
protected

Symbol direction button group.

Definition at line 176 of file qgstextformatwidget.h.

◆ mGeomType

Qgis::GeometryType QgsTextFormatWidget::mGeomType = Qgis::GeometryType::Unknown
protected

Geometry type for layer, if known.

Definition at line 197 of file qgstextformatwidget.h.

◆ mLayer

QgsMapLayer* QgsTextFormatWidget::mLayer = nullptr
protected

Associated vector layer.

Definition at line 192 of file qgstextformatwidget.h.

◆ mMapCanvas

QgsMapCanvas* QgsTextFormatWidget::mMapCanvas = nullptr
protected

Associated map canvas.

Definition at line 183 of file qgstextformatwidget.h.

◆ mMaskedSymbolLayers

QList<QgsSymbolLayerReference> QgsTextFormatWidget::mMaskedSymbolLayers
protected

Definition at line 194 of file qgstextformatwidget.h.

◆ mMinPixelLimit

int QgsTextFormatWidget::mMinPixelLimit = 0
protected

Pixel size font limit.

Definition at line 180 of file qgstextformatwidget.h.

◆ mQuadrantBtnGrp

QButtonGroup* QgsTextFormatWidget::mQuadrantBtnGrp = nullptr
protected

Quadrant button group.

Definition at line 174 of file qgstextformatwidget.h.

◆ mSubstitutions

QgsStringReplacementCollection QgsTextFormatWidget::mSubstitutions
protected

Text substitution list.

Definition at line 172 of file qgstextformatwidget.h.

◆ mUpsidedownBtnGrp

QButtonGroup* QgsTextFormatWidget::mUpsidedownBtnGrp = nullptr
protected

Upside down labels button group.

Definition at line 178 of file qgstextformatwidget.h.

Property Documentation

◆ format

QgsTextFormat QgsTextFormatWidget::format
read

Definition at line 1 of file qgstextformatwidget.h.


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