QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
19 #include <QDesktopWidget>
30 mContext.
setScaleFactor( QgsApplication::desktop()->logicalDpiX() / 25.4 );
44 p.setRenderHint( QPainter::Antialiasing );
66 QRectF textRect = rect();
67 textRect.setLeft( xtrans );
68 textRect.setWidth( textRect.width() - xtrans );
69 textRect.setTop( ytrans );
70 if ( textRect.height() > 300 )
71 textRect.setHeight( 300 );
72 if ( textRect.width() > 2000 )
73 textRect.setWidth( 2000 );
86 void QgsTextPreview::updateContext()
void setIsGuiPreview(bool preview)
Sets GUI preview mode.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
bool enabled() const
Returns whether the background is enabled.
void setParameters(double mapUnitsPerPixel, double centerX, double centerY, int widthPixels, int heightPixels, double rotation)
Sets parameters for use in transforming coordinates.
QgsTextBufferSettings & buffer()
Returns a reference to the text buffer settings.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the size of rendered text.
@ RenderPercentage
Percentage of another measurement (e.g., canvas size, feature size)
void paintEvent(QPaintEvent *e) override
DistanceUnit
Units of distance.
SizeType sizeType() const
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer aro...
void setMapUnits(QgsUnitTypes::DistanceUnit unit)
Sets the map unit type for previewing format sizes in map units.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the shape size.
Container for all settings relating to text rendering.
QSizeF size() const
Returns the size of the background shape.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the size.
void setFlag(Qgis::RenderContextFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
static void drawText(const QRectF &rect, double rotation, HAlignment alignment, const QStringList &textLines, QgsRenderContext &context, const QgsTextFormat &format, bool drawAsOutlines=true, VAlignment vAlignment=AlignTop, Qgis::TextRendererFlags flags=Qgis::TextRendererFlags())
Draws text within a rectangle using the specified settings.
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
QgsTextPreview(QWidget *parent=nullptr)
Constructor for QgsTextPreview.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the buffer size.
double size() const
Returns the size of the buffer.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
double size() const
Returns the size for rendered text.
@ Antialiasing
Use antialiasing while drawing.
bool enabled() const
Returns whether the buffer is enabled.
Perform transforms between map coordinates and device coordinates.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units used for the shape's size.
void setUseAdvancedEffects(bool enabled)
Used to enable or disable advanced effects such as blend modes.
void setFormat(const QgsTextFormat &format)
Sets the text format for previewing in the widget.
static QgsMapToPixel fromScale(double scale, QgsUnitTypes::DistanceUnit mapUnits, double dpi=96)
Returns a new QgsMapToPixel created using a specified scale and distance unit.
void setScale(double scale)
Sets the scale to use for previewing format sizes in map units.
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.