summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2019-04-28 14:08:49 +0200
committerAndré Hartmann <aha_1980@gmx.de>2019-04-29 07:00:43 +0000
commit673495d2eb1fe9cdf701351d75c2203c80ab6ba5 (patch)
tree2f24a5d2505defb20800323ba4ff579dcf65b18d
parentb58c86eddd8fa3fb4a570c5aa2301b1278c4e13c (diff)
CAN Example: Fix entering invalid chars in CAN ID input
The old code returned Intermediate for invalid inputs (e.g. chars outside the A-F range or special characters), because input.toUInt() returned 0 for these cases. Fix that by checking ok from input.toUInt(&ok) first. To allow clearing an edit field containing valid input with backspace again, an additional isEmpty() check has to be added. Change-Id: I4ae28e35ca21611fc5f323b26cdeca75257f1352 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--examples/serialbus/can/sendframebox.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/serialbus/can/sendframebox.cpp b/examples/serialbus/can/sendframebox.cpp
index 117ff10..13042d0 100644
--- a/examples/serialbus/can/sendframebox.cpp
+++ b/examples/serialbus/can/sendframebox.cpp
@@ -72,7 +72,7 @@ QValidator::State HexIntegerValidator::validate(QString &input, int &) const
bool ok;
uint value = input.toUInt(&ok, 16);
- if (!value)
+ if (input.isEmpty())
return Intermediate;
if (!ok || value > m_maximum)