QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
19 #include <QDesktopWidget>
30 mContext.
setScaleFactor( QgsApplication::desktop()->logicalDpiX() / 25.4 );
44 p.setRenderHint( QPainter::Antialiasing );
61 QRectF textRect = rect();
62 textRect.setLeft( xtrans );
63 textRect.setWidth( textRect.width() - xtrans );
64 textRect.setTop( ytrans );
65 if ( textRect.height() > 300 )
66 textRect.setHeight( 300 );
67 if ( textRect.width() > 2000 )
68 textRect.setWidth( 2000 );
81 void QgsTextPreview::updateContext()
void setIsGuiPreview(bool preview)
Sets GUI preview mode.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
static void drawText(const QRectF &rect, double rotation, HAlignment alignment, const QStringList &textLines, QgsRenderContext &context, const QgsTextFormat &format, bool drawAsOutlines=true, VAlignment vAlignment=AlignTop)
Draws text within a rectangle using the specified settings.
bool enabled() const
Returns whether the background is enabled.
void setParameters(double mapUnitsPerPixel, double centerX, double centerY, int widthPixels, int heightPixels, double rotation)
Set parameters for use in transforming coordinates.
QgsTextBufferSettings & buffer()
Returns a reference to the text buffer settings.
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
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.
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.
bool enabled() const
Returns whether the buffer is enabled.
Perform transforms between map coordinates and device coordinates.
@ Antialiasing
Use antialiasing while drawing.
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.