aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2021-05-04 15:48:28 +0200
committerMitch Curtis <mitch.curtis@qt.io>2021-05-11 15:47:19 +0200
commita063cd0be5e8f108a0084831856f4af8c0e9159c (patch)
treeea7f6b7c63a28debff7799df35d0c1adfda2a012 /tests/auto
parent468def83fc713e329ef9b2e150653837fe895159 (diff)
ToolTip: use contentWidth of Text contentItem to account for newlines
By default, QQuickPopupItem uses the implicitWidth of its contentItem, which is too large in the case of a ToolTip with newlines in the text. In that case, contentWidth refers to the width of the text including newlines, so we use that instead. [ChangeLog][Controls][ToolTip] The implicit width of ToolTips now accounts for newlines in the text. If you want to use the old behavior, set ToolTip's contentWidth to implicitContentWidth. Fixes: QTBUG-83630 Pick-to: 6.1 5.15 Change-Id: I7ca3805429acb68a13ead8f3545bb84a51fb1b72 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/controls/data/tst_tooltip.qml18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_tooltip.qml b/tests/auto/controls/data/tst_tooltip.qml
index b4e992a4..2f98a5f3 100644
--- a/tests/auto/controls/data/tst_tooltip.qml
+++ b/tests/auto/controls/data/tst_tooltip.qml
@@ -75,6 +75,11 @@ TestCase {
SignalSpy { }
}
+ Component {
+ id: itemComponent
+ Item {}
+ }
+
QtObject {
id: object
}
@@ -446,6 +451,19 @@ TestCase {
verify(item.ToolTip.toolTip.contentItem.width < item.ToolTip.toolTip.contentItem.implicitWidth)
}
+ // QTBUG-83630: Test that newlines are accounted for in the implicit contentWidth.
+ function test_newLines() {
+ var item = createTemporaryObject(itemComponent, testCase)
+ verify(item)
+
+ item.ToolTip.show("This is one line of text\nThis is another line of text")
+
+ // The implicitWidth of the Text item for the text above will be larger than
+ // its contentWidth. ToolTip's implicitWidth uses contentWidth in its calculation,
+ // so we check that it's less than the Text's implicitWidth.
+ verify(item.ToolTip.toolTip.implicitWidth < item.ToolTip.toolTip.contentItem.implicitWidth)
+ }
+
function test_timeoutAfterOpened() {
let control = createTemporaryObject(toolTipWithExitTransition, testCase, { timeout: 1, exit: null })
verify(control)