QLineedit Multiple Validation
I have a LineEdit. I need to validate the input of this lineEdit for Latitude and longitude!
i.e., i have only one lineedit in which i have to validate the first to digits for 0-90 the next two for 0-60 and the next two for 0-60 and the last for [NWES].
will the method of reqexp work here!
if so how will i add input mask.
--
Thanks
Re: QLineedit Multiple Validation
You have many different choices here. I'd go for providing a custom (not regexp) validator. Another choice is to implement a spinbox that will let you set the coordinates just as QDateTimeEdit does for date and time.
Re: QLineedit Multiple Validation
i dont want to use a spin box..
i would like to use a lineedit only, in that case, how will i write a custom validator without regexp?
some examples or tips please..
Re: QLineedit Multiple Validation
Implement a subclass of QValidator?
Re: QLineedit Multiple Validation
is thereany method in QString that is equivalent to
char charAt(int );
that is i need a method that will give the character at the index given.
Re: QLineedit Multiple Validation
Re: QLineedit Multiple Validation
is it possible to find out who has called a particular slot when there are many senders connected to the same slot for the same signal.?
i have a slot that should be called when a lineedit looses its focus and i will set the lineedit's text to some value. this is done by a custom slot.
now i will have many lineedits connected to same slot so that only the particular lineedit which has lost the focus will have the text set. how will i do this.?
--
Thanks
Re: QLineedit Multiple Validation
Yes...
By QObject::sender () you can find the sender, cast it into proper object and you are done :)
Re: QLineedit Multiple Validation
Re: QLineedit Multiple Validation
Quote:
Originally Posted by
csvivek
is it possible to find out who has called a particular slot when there are many senders connected to the same slot for the same signal.?
i have a slot that should be called when a lineedit looses its focus and i will set the lineedit's text to some value. this is done by a custom slot.
now i will have many lineedits connected to same slot so that only the particular lineedit which has lost the focus will have the text set. how will i do this.?
But really... why not use a subclass of QValidator? Unless you are using sender() for some other purpose than validating the input.
Re: QLineedit Multiple Validation
i think that will be a bit complex!
Re: QLineedit Multiple Validation
Complex? Like... 10 lines of code?
Re: QLineedit Multiple Validation
Quote:
Originally Posted by
wysota
Complex? Like... 10 lines of code?
Hi!
Could someone write a simple code of QLineEdit Validation? (maybe for 2 QLineEdits?).
Thanks in advance!!
Cheers.
Re: QLineedit Multiple Validation
You can validate lat/long with a regexp:
Code:
QRegExp rx
("([0-8][0-9])|([0-9]0?)\s*[NS]\s+(1[0-7][0-9])|(180)|([0-9][0-9]?)\s*[EW]");