QgsTextPreview class

A widget for previewing text formatting settings.

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

In order to preview the exact appearance of text which uses sizes in map units, the scale and map units must be set by calling setScale() and setMapUnits().

Constructors, destructors, conversion operators

QgsTextPreview(QWidget* parent = nullptr)
Constructor for QgsTextPreview.

Public functions

auto format() const -> QgsTextFormat
Returns the text format used for previewing text in the widget.
auto mapUnits() const -> QgsUnitTypes::DistanceUnit
Returns the map unit type used for previewing format sizes in map units.
auto scale() const -> double
Returns the scale used for previewing format sizes in map units.
void setFormat(const QgsTextFormat& format)
Sets the text format for previewing in the widget.
void setMapUnits(QgsUnitTypes::DistanceUnit unit)
Sets the map unit type for previewing format sizes in map units.
void setScale(double scale)
Sets the scale to use for previewing format sizes in map units.

Function documentation

QgsTextPreview::QgsTextPreview(QWidget* parent = nullptr)

Constructor for QgsTextPreview.

Parameters
parent parent widget

QgsTextFormat QgsTextPreview::format() const

Returns the text format used for previewing text in the widget.

QgsUnitTypes::DistanceUnit QgsTextPreview::mapUnits() const

Returns the map unit type used for previewing format sizes in map units.

double QgsTextPreview::scale() const

Returns the scale used for previewing format sizes in map units.

The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.

void QgsTextPreview::setFormat(const QgsTextFormat& format)

Sets the text format for previewing in the widget.

Parameters
format text format

void QgsTextPreview::setMapUnits(QgsUnitTypes::DistanceUnit unit)

Sets the map unit type for previewing format sizes in map units.

Parameters
unit map units

void QgsTextPreview::setScale(double scale)

Sets the scale to use for previewing format sizes in map units.

The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.