summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2023-05-12 15:46:54 +0800
committerEdward Welbourne <edward.welbourne@qt.io>2023-05-17 01:43:15 +0000
commitf69b5f260e301dc01c7d85cd1cb9d45582ef3d6d (patch)
treea9c449024c8f7bf8c974682c65e94702e0d9d17a
parent94475c9e533dc8b05c606c92b91ab2b645960ac0 (diff)
downloadqtdeclarative-f69b5f260e301dc01c7d85cd1cb9d45582ef3d6d.tar.gz
QQuickMaterialPlaceholderText: fix code checker complaint
The message was: result of integer division used in a floating point context; possible loss of precision Fixing it revealed a test that relied on it; removed the Math.floor() work-around the test used previously. Pick-to: 6.5 Change-Id: I7c2fde1902d2013ba9fedcadf87ae3b21987fca2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
-rw-r--r--src/quickcontrols/material/impl/qquickmaterialplaceholdertext.cpp2
-rw-r--r--tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/quickcontrols/material/impl/qquickmaterialplaceholdertext.cpp b/src/quickcontrols/material/impl/qquickmaterialplaceholdertext.cpp
index 8533802a5a..2aa81f68a3 100644
--- a/src/quickcontrols/material/impl/qquickmaterialplaceholdertext.cpp
+++ b/src/quickcontrols/material/impl/qquickmaterialplaceholdertext.cpp
@@ -146,7 +146,7 @@ qreal QQuickMaterialPlaceholderText::floatingTargetY() const
// Outlined text fields have the placeaholder vertically centered
// along the outline at the top.
- return (-m_largestHeight / 2) + controlTopInset(textControl());
+ return (-m_largestHeight / 2.0) + controlTopInset(textControl());
}
/*!
diff --git a/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml b/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml
index aac3bbd832..fb516ec669 100644
--- a/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml
+++ b/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml
@@ -1070,7 +1070,7 @@ TestCase {
// The placeholder text should always float at a fixed position at the top
// when text has been set, even when it's in a Flickable.
flickable.contentY = -50
- compare(placeholderTextItem.y, -Math.floor(placeholderTextItem.largestHeight / 2))
+ compare(placeholderTextItem.y, -placeholderTextItem.largestHeight / 2)
flickable.contentY = 0
// When the text is cleared, it shouldn't float.