How to check string contains more than one dot in qt ?
-
I want to put validation for entered typed data by user.
maximum character in typed data is 3 and it not contain more than one dot.
so i have written below code to implement it where MINIMUM_BG =0.0 & MAXIMUM_BG =5.0 .
But below logic become wrong when user enter ".1.". so how to put validation for this type of string when it contain more than one dot in qt?
my key board contains " 0-9 " and one " . " .
if((sTypedData.toFloat()< MINIMUM_BG)||(sTypedData.toFloat() > MAXIMUM_BG) || sTypedData.contains("..") )
WrongValue(sTypedData);
else
CorrectValue(sTypedData); -
I want to put validation for entered typed data by user.
maximum character in typed data is 3 and it not contain more than one dot.
so i have written below code to implement it where MINIMUM_BG =0.0 & MAXIMUM_BG =5.0 .
But below logic become wrong when user enter ".1.". so how to put validation for this type of string when it contain more than one dot in qt?
my key board contains " 0-9 " and one " . " .
if((sTypedData.toFloat()< MINIMUM_BG)||(sTypedData.toFloat() > MAXIMUM_BG) || sTypedData.contains("..") )
WrongValue(sTypedData);
else
CorrectValue(sTypedData);@Qt-embedded-developer
" How to check string contains more than one dot in qt ?" - https://doc.qt.io/qt-5/qstring.html#count-2 -
@Qt-embedded-developer
" How to check string contains more than one dot in qt ?" - https://doc.qt.io/qt-5/qstring.html#count-2@jsulm Thanks.