aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-05-03 12:21:54 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2021-05-03 15:09:04 +0200
commit42687caf7bc7496b838995f3fa68194ca8323da3 (patch)
tree574ada990010e90528750e58ac9a7beae3683451 /tests/auto/controls
parent344f3435e442827d0365f28d2e81aa5160207773 (diff)
QQuickDial: Keep value integer if everything is integer
If a user uses integer values for stepSize, from and to in a Dial, they most likely want the actual values of the Dial to be integers, too. Detect this condition, and store it in a new boolean member. If the condition is met, we round the value in QQuickDialPrivate::valueAt (which, due to floating point math might not be an exact integer). As a drive-by, reorder the boolean members to introduce no additional space overhead. Pick-to: 6.1 5.15 Fixes: QTBUG-92214 Change-Id: If4633fae1d7d425ca7fb767c7284d6f8ea7ce78c Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/controls')
-rw-r--r--tests/auto/controls/data/tst_dial.qml15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_dial.qml b/tests/auto/controls/data/tst_dial.qml
index 70645f8d..2d0c702e 100644
--- a/tests/auto/controls/data/tst_dial.qml
+++ b/tests/auto/controls/data/tst_dial.qml
@@ -691,4 +691,19 @@ TestCase {
compare(control.pressed, false);
compare(control.position, data.expectedPosition);
}
+
+ function test_integerStepping() {
+ var dial = createTemporaryObject(dialComponent, testCase)
+ verify(dial)
+
+ dial.from = 1
+ dial.to = 8
+ dial.stepSize = 1
+
+ for (let i = 1; i < 8; ++i) {
+ // compare as strings to avoid a fuzzy compare; we want an exact match
+ compare(""+dial.value, ""+1)
+ keyClick(Qt.Key_Right)
+ }
+ }
}