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.cpp
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
5
6#include <QFont>
7#include <QTextOption>
8
10
42 QObject(parent),
43 m_metrics(m_font),
44 m_elide(Qt::ElideNone),
45 m_elideWidth(0),
46 m_renderType(QQuickText::QtRendering)
47{
48}
49
56{
57 return m_font;
58}
59
61{
62 if (m_font != font) {
63 m_font = font;
64 m_metrics = QFontMetricsF(m_font);
67 }
68}
69
76{
77 return m_text;
78}
79
81{
82 if (m_text != text) {
83 m_text = text;
86 }
87}
88
103{
104 return m_elide;
105}
106
108{
109 if (m_elide != elide) {
110 m_elide = elide;
113 }
114}
115
125{
126 return m_elideWidth;
127}
128
130{
131 if (m_elideWidth != elideWidth) {
132 m_elideWidth = elideWidth;
135 }
136}
137
153
163{
166 return m_metrics.boundingRect(m_text, option);
167}
168
182{
183 return boundingRect().width();
184}
185
199{
200 return boundingRect().height();
201}
202
217
229{
230 return m_metrics.elidedText(m_text, m_elide, m_elideWidth);
231}
232
249{
250 return m_renderType;
251}
252
254{
255 if (m_renderType == renderType)
256 return;
257
258 m_renderType = renderType;
260}
261
263
264#include "moc_qquicktextmetrics_p.cpp"
\reentrant \inmodule QtGui
QRectF boundingRect(const QString &string) const
Returns the bounding rectangle of the characters in the string specified by text.
qreal horizontalAdvance(const QString &string, int length=-1) const
Returns the horizontal advance in pixels of the first length characters of text.
QRectF tightBoundingRect(const QString &text) const
QString elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags=0) const
\reentrant
Definition qfont.h:22
\inmodule QtCore
Definition qobject.h:103
void setElideWidth(qreal elideWidth)
void setRenderType(QQuickText::RenderType renderType)
void setText(const QString &text)
QQuickTextMetrics(QObject *parent=nullptr)
\qmltype TextMetrics \instantiates QQuickTextMetrics \inqmlmodule QtQuick
void renderTypeChanged()
QQuickText::RenderType renderType
void setFont(const QFont &font)
void setElide(Qt::TextElideMode elide)
Qt::TextElideMode elide
void elideWidthChanged()
\inmodule QtCore\reentrant
Definition qrect.h:484
constexpr qreal height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:732
constexpr qreal width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:729
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\reentrant
Definition qtextoption.h:18
void setUseDesignMetrics(bool b)
If enable is true then the layout will use design metrics; otherwise it will use the metrics of the p...
Definition qtextoption.h:91
QString text
Combined button and popup list for selecting options.
Definition qcompare.h:63
TextElideMode
Definition qnamespace.h:188
GLuint GLenum option
#define emit
double qreal
Definition qtypes.h:187