Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKTEXTMETRICS_H
6#define QQUICKTEXTMETRICS_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qtquickglobal_p.h>
20#include <private/qquicktext_p.h>
21
22#include <QtCore/qobject.h>
23
24#include <QtGui/qfontmetrics.h>
25
26#include <QtQml/qqml.h>
27
28QT_BEGIN_NAMESPACE
29
30class QFont;
31
32class Q_QUICK_EXPORT QQuickTextMetrics : public QObject
33{
34 Q_OBJECT
35
36 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged FINAL)
37 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
38 Q_PROPERTY(qreal advanceWidth READ advanceWidth NOTIFY metricsChanged FINAL)
39 Q_PROPERTY(QRectF boundingRect READ boundingRect NOTIFY metricsChanged FINAL)
40 Q_PROPERTY(qreal width READ width NOTIFY metricsChanged FINAL)
41 Q_PROPERTY(qreal height READ height NOTIFY metricsChanged FINAL)
42 Q_PROPERTY(QRectF tightBoundingRect READ tightBoundingRect NOTIFY metricsChanged FINAL)
43 Q_PROPERTY(QString elidedText READ elidedText NOTIFY metricsChanged FINAL)
44 Q_PROPERTY(Qt::TextElideMode elide READ elide WRITE setElide NOTIFY elideChanged FINAL)
45 Q_PROPERTY(qreal elideWidth READ elideWidth WRITE setElideWidth NOTIFY elideWidthChanged FINAL)
46 Q_PROPERTY(QQuickText::RenderType renderType READ renderType WRITE setRenderType
47 NOTIFY renderTypeChanged)
48 QML_NAMED_ELEMENT(TextMetrics)
49 QML_ADDED_IN_VERSION(2, 4)
50
51public:
52 explicit QQuickTextMetrics(QObject *parent = nullptr);
53
54 QFont font() const;
55 void setFont(const QFont &font);
56
57 QString text() const;
58 void setText(const QString &text);
59
60 Qt::TextElideMode elide() const;
61 void setElide(Qt::TextElideMode elide);
62
63 qreal elideWidth() const;
64 void setElideWidth(qreal elideWidth);
65
66 qreal advanceWidth() const;
67 QRectF boundingRect() const;
68 qreal width() const;
69 qreal height() const;
70 QRectF tightBoundingRect() const;
71 QString elidedText() const;
72
73 QQuickText::RenderType renderType() const;
74 void setRenderType(QQuickText::RenderType renderType);
75
76Q_SIGNALS:
77 void fontChanged();
78 void textChanged();
79 void elideChanged();
80 void elideWidthChanged();
81 void metricsChanged();
82 void renderTypeChanged();
83
84private:
85 QString m_text;
86 QFont m_font;
87 QFontMetricsF m_metrics;
88 Qt::TextElideMode m_elide;
89 qreal m_elideWidth;
90 QQuickText::RenderType m_renderType;
91};
92
93QT_END_NAMESPACE
94
95#endif // QQUICKTEXTMETRICS_H