Home » Community » Newbie corner » [SOLVED] Empty values to the "EditInt" widget and the "int" basic type
[SOLVED] Empty values to the "EditInt" widget and the "int" basic type [message #52589] |
Thu, 24 October 2019 22:30  |
xrysf03
Messages: 43 Registered: November 2018 Location: CZ
|
Member |
|
|
Hello everybody,
another stupid noob question.
In a simple GUI application, I have two EditInt widgets, called From and To.
I understand that the EditInt is a subclass of an "Editbox" that can only accept integers.
The EditInt widget is willing to remain empty - in which case I would understand that it contains no valid integer value. But, to the best of my knowledge, a traditional "int" type does not have a NaN value. So I was wondering if there's a way for me to test, if the EditInt widget contains a valid integer value, or is empty. I haven't found any such member function or flag to the EditInt object...
I've tried assigning the value of the EditInt widget to a basic "int" variable, declared locally in a function. And then I passed that int variable into a String, and I printed that string.
What I find shocking: the empty value from the editbox apparently made it into the printed string as an empty string, i.e. "".
This is my code almost verbatim:
String tmp_str;
int _from, _to;
_from = Edit_from;
_to = Edit_to;
tmp_str << "From: " << _from << " To: " << _to;
log_this(tmp_str);
...and in the log I get:
"From: To: "
If I type in some numbers, I get those numbers. E.g.:
"From: 100 To: 200"
Is the "int" type overloaded with some higher-level class?
Is there a way for me to test the EditInt or the basic "int" type for an empty value?
I need this for basic user input sanitization.
Frank Rysanek
[Updated on: Fri, 25 October 2019 11:00] Report message to a moderator
|
|
|
|
|
|
Goto Forum:
Current Time: Tue May 13 11:26:39 CEST 2025
Total time taken to generate the page: 0.02369 seconds
|