diff options
author | Timur Kristóf <timur.kristof@gmail.com> | 2019-09-27 18:07:41 +0200 |
---|---|---|
committer | Timur Kristóf <timur.kristof@gmail.com> | 2019-11-04 09:39:10 +0200 |
commit | b25c27d37a5d5dded723946900f9a518c38385de (patch) | |
tree | bae23ac214ae9bebb394550ecfb752e138e31c6a /src/quick/items/qquicktext_p.h | |
parent | bd62eff7ca551dc76cf1ec2e7eef14664f6228a5 (diff) |
Add API to get more information for each line in a QML Text element
Previously there was no way to know what area is occupied by each line
in a QML Text element.
This commit adds new API to expose implicitWidth and isLast
on QQuickTextLine for use in the lineLaidOut signal.
It also adds improved documentation to the lineLaidOut signal and
an example usage of the new API to the text layout example.
An example use case of the new API is eg. to allow embedding
timestamps and indicators within a text paragraph, to enable
creating more efficient layouts.
[ChangeLog][QtQuick][Text] Added new API that exposes implicitWidth,
and isLast on the QQuickTextLine for use in the lineLaidOut signal.
This allows the user to layout other items relative to the lines
of text.
Fixes: QTBUG-78277
Change-Id: Ibc754db17c78efb01468106aba32e30d70d2f4df
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquicktext_p.h')
-rw-r--r-- | src/quick/items/qquicktext_p.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h index 394ea25b83..d310db508e 100644 --- a/src/quick/items/qquicktext_p.h +++ b/src/quick/items/qquicktext_p.h @@ -330,6 +330,8 @@ class QQuickTextLine : public QObject Q_PROPERTY(qreal height READ height WRITE setHeight) Q_PROPERTY(qreal x READ x WRITE setX) Q_PROPERTY(qreal y READ y WRITE setY) + Q_PROPERTY(qreal implicitWidth READ implicitWidth) + Q_PROPERTY(bool isLast READ isLast) QML_ANONYMOUS public: @@ -337,7 +339,10 @@ public: void setLine(QTextLine* line); void setLineOffset(int offset); + void setFullLayoutTextLength(int length); int number() const; + qreal implicitWidth() const; + bool isLast() const; qreal width() const; void setWidth(qreal width); @@ -355,6 +360,7 @@ private: QTextLine *m_line; qreal m_height; int m_lineOffset; + int m_fullLayoutTextLength; }; QT_END_NAMESPACE |