Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquicktextmetrics_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKTEXTMETRICS_H
5#define QQUICKTEXTMETRICS_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qtquickglobal_p.h>
19#include <private/qquicktext_p.h>
20
21#include <QtCore/qobject.h>
22
23#include <QtGui/qfontmetrics.h>
24
25#include <QtQml/qqml.h>
26
28
29class QFont;
30
31class Q_QUICK_EXPORT QQuickTextMetrics : public QObject
32{
34
35 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged FINAL)
36 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
37 Q_PROPERTY(qreal advanceWidth READ advanceWidth NOTIFY metricsChanged FINAL)
38 Q_PROPERTY(QRectF boundingRect READ boundingRect NOTIFY metricsChanged FINAL)
39 Q_PROPERTY(qreal width READ width NOTIFY metricsChanged FINAL)
40 Q_PROPERTY(qreal height READ height NOTIFY metricsChanged FINAL)
41 Q_PROPERTY(QRectF tightBoundingRect READ tightBoundingRect NOTIFY metricsChanged FINAL)
42 Q_PROPERTY(QString elidedText READ elidedText NOTIFY metricsChanged FINAL)
43 Q_PROPERTY(Qt::TextElideMode elide READ elide WRITE setElide NOTIFY elideChanged FINAL)
44 Q_PROPERTY(qreal elideWidth READ elideWidth WRITE setElideWidth NOTIFY elideWidthChanged FINAL)
45 Q_PROPERTY(QQuickText::RenderType renderType READ renderType WRITE setRenderType
46 NOTIFY renderTypeChanged)
47 QML_NAMED_ELEMENT(TextMetrics)
49
50public:
51 explicit QQuickTextMetrics(QObject *parent = nullptr);
52
53 QFont font() const;
54 void setFont(const QFont &font);
55
56 QString text() const;
57 void setText(const QString &text);
58
59 Qt::TextElideMode elide() const;
60 void setElide(Qt::TextElideMode elide);
61
62 qreal elideWidth() const;
63 void setElideWidth(qreal elideWidth);
64
65 qreal advanceWidth() const;
66 QRectF boundingRect() const;
67 qreal width() const;
68 qreal height() const;
69 QRectF tightBoundingRect() const;
70 QString elidedText() const;
71
72 QQuickText::RenderType renderType() const;
73 void setRenderType(QQuickText::RenderType renderType);
74
76 void fontChanged();
78 void elideChanged();
79 void elideWidthChanged();
80 void metricsChanged();
81 void renderTypeChanged();
82
84 QString m_text;
85 QFont m_font;
86 QFontMetricsF m_metrics;
87 Qt::TextElideMode m_elide;
88 qreal m_elideWidth;
89 QQuickText::RenderType m_renderType;
90};
91
93
94#endif // QQUICKTEXTMETRICS_H
\reentrant \inmodule QtGui
\reentrant
Definition qfont.h:22
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qrect.h:484
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QString text
void textChanged(const QString &newText)
Combined button and popup list for selecting options.
Definition qcompare.h:63
GLint GLsizei GLsizei height
GLint GLsizei width
static const QRectF boundingRect(const QPointF *points, int pointCount)
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
#define explicit
insertRed setText("insert red text")