QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgstextpreview.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstextpreview.h
3 ----------------
4 begin : October 2016
5 copyright : (C) 2016 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#ifndef QGSTEXTPREVIEW_H
16#define QGSTEXTPREVIEW_H
17
18#include "qgis_gui.h"
19#include "qgsrendercontext.h"
20#include "qgstextformat.h"
21
22#include <QLabel>
23
24class QgsScreenHelper;
25
39
40class GUI_EXPORT QgsTextPreview : public QLabel
41{
42 Q_OBJECT
43
44 Q_PROPERTY( QgsTextFormat format READ format WRITE setFormat )
45 Q_PROPERTY( double scale READ scale WRITE setScale )
46 Q_PROPERTY( Qgis::DistanceUnit mapUnits READ mapUnits WRITE setMapUnits )
47
48 public:
53 QgsTextPreview( QWidget *parent = nullptr );
54
55 void paintEvent( QPaintEvent *e ) override;
56
62 void setFormat( const QgsTextFormat &format );
63
68 QgsTextFormat format() const { return mFormat; }
69
76 void setScale( double scale );
77
84 double scale() const { return mScale; }
85
92 void setMapUnits( Qgis::DistanceUnit unit );
93
99 Qgis::DistanceUnit mapUnits() const { return mMapUnits; }
100
101 private:
102 QgsScreenHelper *mScreenHelper = nullptr;
103
104 QgsTextFormat mFormat;
105 QgsRenderContext mContext;
106 double mScale = -1;
108 void updateContext();
109};
110
111#endif // QGSTEXTPREVIEW_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:56
DistanceUnit
Units of distance.
Definition qgis.h:5013
@ Meters
Meters.
Definition qgis.h:5014
Contains information about the context of a rendering operation.
A utility class for dynamic handling of changes to screen properties.
Container for all settings relating to text rendering.
void setScale(double scale)
Sets the scale to use for previewing format sizes in map units.
void paintEvent(QPaintEvent *e) override
QgsTextFormat format
QgsTextPreview(QWidget *parent=nullptr)
Constructor for QgsTextPreview.
Qgis::DistanceUnit mapUnits() const
Returns the map unit type used for previewing format sizes in map units.
double scale() const
Returns the scale used for previewing format sizes in map units.
void setMapUnits(Qgis::DistanceUnit unit)
Sets the map unit type for previewing format sizes in map units.
Qgis::DistanceUnit mapUnits
void setFormat(const QgsTextFormat &format)
Sets the text format for previewing in the widget.