17 #include <QDesktopWidget> 28 mContext.
setScaleFactor( QgsApplication::desktop()->logicalDpiX() / 25.4 );
38 p.setRenderHint( QPainter::Antialiasing );
55 QRectF textRect = rect();
56 textRect.setLeft( xtrans );
57 textRect.setWidth( textRect.width() - xtrans );
58 textRect.setTop( ytrans );
59 if ( textRect.height() > 300 )
60 textRect.setHeight( 300 );
61 if ( textRect.width() > 2000 )
62 textRect.setWidth( 2000 );
75 void QgsTextPreview::updateContext()
QSizeF size() const
Returns the size of the background shape.
QgsTextPreview(QWidget *parent=nullptr)
Constructor for QgsTextPreview.
void setScale(double scale)
Sets the scale to use for previewing format sizes in map units.
double scale() const
Returns the scale used for previewing format sizes in map units.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
Perform transforms between map coordinates and device coordinates.
void setUseAdvancedEffects(bool enabled)
Used to enable or disable advanced effects such as blend modes.
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
static QgsMapToPixel fromScale(double scale, QgsUnitTypes::DistanceUnit mapUnits, double dpi=96)
Returns a new QgsMapToPixel created using a specified scale and distance unit.
void setMapUnits(QgsUnitTypes::DistanceUnit unit)
Sets the map unit type for previewing format sizes in map units.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
QgsTextBufferSettings & buffer()
Returns a reference to the text buffer settings.
QgsTextFormat format() const
Returns the text format used for previewing text in the widget.
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.
void setFormat(const QgsTextFormat &format)
Sets the text format for previewing in the widget.
DistanceUnit
Units of distance.
void setParameters(double mapUnitsPerPixel, double centerX, double centerY, int widthPixels, int heightPixels, double rotation)
Set parameters for use in transforming coordinates.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
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 background is enabled.
void setMapToPixel(const QgsMapToPixel &mtp)
SizeType sizeType() const
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer aro...
bool enabled() const
Returns whether the buffer is enabled.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the shape size.
Container for all settings relating to text rendering.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units used for the shape's size.
void paintEvent(QPaintEvent *e) override