diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-05-03 12:21:54 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-05-04 10:31:27 +0200 |
commit | f9bc1b540413466b53ecf6d15016422ada314181 (patch) | |
tree | 5de93b607c0401233cd3079e4e7d8d9511327a6c /tests | |
parent | 16d946701d7fc38fce264ffdb4d5443ffcb50514 (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.
Fixes: QTBUG-92214
Change-Id: If4633fae1d7d425ca7fb767c7284d6f8ea7ce78c
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit 42687caf7bc7496b838995f3fa68194ca8323da3)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_dial.qml | 15 |
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 26f30c33..e3ad2b2f 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) + } + } } |