aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-01-13 08:40:29 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-01-14 05:02:57 +0000
commitefa22507386d3a0dcc97b703219dcf9714f55a8d (patch)
tree6bd165292ec835382c4ea933fb0dd4868faa1c42
parente85ebe01b61a64ed64592dedb71c5913cd5080fd (diff)
Deprecate Text::doLayout() in favor of forceLayout()
Item views and positioners all have now forceLayout(), so make the Text element API consistent with them. The old doLayout(), which sounds more like an internal helper method, is deprecated and marked for removal in Qt 6. [ChangeLog][QtQuick][Text] Deprecated doLayout() in favor of forceLayout(). Change-Id: I051988fca13c4cd84904f7b268d51f6a96f28af3 Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
-rw-r--r--src/quick/items/qquickitemsmodule.cpp1
-rw-r--r--src/quick/items/qquicktext.cpp14
-rw-r--r--src/quick/items/qquicktext_p.h3
-rw-r--r--tests/testapplications/textlayout/styledtext-layout.qml2
4 files changed, 17 insertions, 3 deletions
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index 5bba52ed73..a8824de9c8 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -376,6 +376,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickFlickable, 9>(uri, 2, 9, "Flickable");
qmlRegisterType<QQuickMouseArea, 9>(uri, 2, 9, "MouseArea");
+ qmlRegisterType<QQuickText, 9>(uri, 2, 9, "Text");
qmlRegisterType<QQuickTextInput, 9>(uri, 2, 9, "TextInput");
qmlRegisterType<QQuickTouchPoint>(uri, 2, 9, "TouchPoint");
qRegisterMetaType<QPointingDeviceUniqueId>("QPointingDeviceUniqueId");
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 30e9c71143..965fb0102f 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -2795,11 +2795,23 @@ void QQuickText::setRenderType(QQuickText::RenderType renderType)
/*!
\qmlmethod QtQuick::Text::doLayout()
+ \deprecated
- Triggers a re-layout of the displayed text.
+ Use \l forceLayout() instead.
*/
void QQuickText::doLayout()
{
+ forceLayout();
+}
+
+/*!
+ \qmlmethod QtQuick::Text::forceLayout()
+ \since 5.9
+
+ Triggers a re-layout of the displayed text.
+*/
+void QQuickText::forceLayout()
+{
Q_D(QQuickText);
d->updateSize();
}
diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h
index 40dbd51f39..c3d3906e7e 100644
--- a/src/quick/items/qquicktext_p.h
+++ b/src/quick/items/qquicktext_p.h
@@ -218,7 +218,8 @@ public:
QRectF boundingRect() const Q_DECL_OVERRIDE;
QRectF clipRect() const Q_DECL_OVERRIDE;
- Q_INVOKABLE void doLayout();
+ Q_INVOKABLE void doLayout(); // ### Qt 6: remove
+ Q_REVISION(9) Q_INVOKABLE void forceLayout();
RenderType renderType() const;
void setRenderType(RenderType renderType);
diff --git a/tests/testapplications/textlayout/styledtext-layout.qml b/tests/testapplications/textlayout/styledtext-layout.qml
index 4ad0c7e279..80f62a6b8f 100644
--- a/tests/testapplications/textlayout/styledtext-layout.qml
+++ b/tests/testapplications/textlayout/styledtext-layout.qml
@@ -88,7 +88,7 @@ Rectangle {
drag.target: rect
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: mouse.button == Qt.RightButton ? myText.font.pixelSize -= 1 : myText.font.pixelSize += 1
- onPositionChanged: myText.doLayout()
+ onPositionChanged: myText.forceLayout()
}
}
}