QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgstextfragment.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgstextfragment.h
3  -----------------
4  begin : May 2020
5  copyright : (C) 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 
16 #ifndef QGSTEXTFRAGMENT_H
17 #define QGSTEXTFRAGMENT_H
18 
19 #include "qgis_sip.h"
20 #include "qgis_core.h"
21 #include "qgstextcharacterformat.h"
22 
23 class QTextFragment;
24 
34 class CORE_EXPORT QgsTextFragment
35 {
36  public:
37 
41  explicit QgsTextFragment( const QString &text = QString(), const QgsTextCharacterFormat &format = QgsTextCharacterFormat() );
42 
46  explicit QgsTextFragment( const QTextFragment &fragment );
47 
53  QString text() const;
54 
60  void setText( const QString &text );
61 
67  const QgsTextCharacterFormat &characterFormat() const { return mCharFormat; }
68 
74  void setCharacterFormat( const QgsTextCharacterFormat &format );
75 
83  double horizontalAdvance( const QFont &font, bool fontHasBeenUpdatedForFragment = false ) const;
84 
85  private:
86 
87  QString mText;
88  QgsTextCharacterFormat mCharFormat;
89 };
90 
91 #endif // QGSTEXTFRAGMENT_H
QgsTextCharacterFormat
Definition: qgstextcharacterformat.h:39
QgsTextFragment
Definition: qgstextfragment.h:34
qgstextcharacterformat.h
qgis_sip.h
QgsTextFragment::characterFormat
const QgsTextCharacterFormat & characterFormat() const
Returns the character formatting for the fragment.
Definition: qgstextfragment.h:67