QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
19 #include <QDesktopWidget>
30 mContext.
setScaleFactor( QgsApplication::desktop()->logicalDpiX() / 25.4 );
42 p.setRenderHint( QPainter::Antialiasing );
59 QRectF textRect = rect();
60 textRect.setLeft( xtrans );
61 textRect.setWidth( textRect.width() - xtrans );
62 textRect.setTop( ytrans );
63 if ( textRect.height() > 300 )
64 textRect.setHeight( 300 );
65 if ( textRect.width() > 2000 )
66 textRect.setWidth( 2000 );
79 void QgsTextPreview::updateContext()
QgsTextBufferSettings & buffer()
Returns a reference to the text buffer settings.
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.
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.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
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.
static void drawText(const QRectF &rect, double rotation, HAlignment alignment, const QStringList &textLines, QgsRenderContext &context, const QgsTextFormat &format, bool drawAsOutlines=true)
Draws text within a rectangle using the specified settings.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the shape size.
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.
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
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.