QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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 "qgstextformat.h"
19#include "qgsrendercontext.h"
20
21#include <QLabel>
22#include "qgis_gui.h"
23
24class QgsScreenHelper;
25
41class GUI_EXPORT QgsTextPreview : public QLabel
42{
43 Q_OBJECT
44
45 Q_PROPERTY( QgsTextFormat format READ format WRITE setFormat )
46 Q_PROPERTY( double scale READ scale WRITE setScale )
47 Q_PROPERTY( Qgis::DistanceUnit mapUnits READ mapUnits WRITE setMapUnits )
48
49 public:
50
55 QgsTextPreview( QWidget *parent = nullptr );
56
57 void paintEvent( QPaintEvent *e ) override;
58
64 void setFormat( const QgsTextFormat &format );
65
70 QgsTextFormat format() const { return mFormat; }
71
78 void setScale( double scale );
79
86 double scale() const { return mScale; }
87
94 void setMapUnits( Qgis::DistanceUnit unit );
95
101 Qgis::DistanceUnit mapUnits() const { return mMapUnits; }
102
103 private:
104
105 QgsScreenHelper *mScreenHelper = nullptr;
106
107 QgsTextFormat mFormat;
108 QgsRenderContext mContext;
109 double mScale = -1;
111 void updateContext();
112};
113
114#endif // QGSTEXTPREVIEW_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
DistanceUnit
Units of distance.
Definition qgis.h:3496
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.
A widget for previewing text formatting settings.
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.