Consider this problem.
I have a QLineEdit in my tool and I should organize a support as follows. The text of LineEdit must contain only double values, separated my comas. F.e. 6.2 , 8, 9.0, 55 I also must validate, that user cannot input any other character but the numbers and comas. Also I should write a method which convert this text into vector. Initially I thought about QRegExp and boost::spirit. But it can be hard using these technique.
Any ideas?
Use next custom Validator.
Header:
Cpp:
Usage:
Explanation about:
val.setLocale(QLocale(QLocale::German,QLocale::Germany));
You said that you want use
6.2,...
but.
and,
is different decimal point in different countries. So I wrote example accordingly to your question. German Locale always think that.
is a correct point.But I recommend you to use locale-specific decimal point and use for this Purpose ; as separator instead of coma.
There are mistakes, so try this. Edit(improved):