PDA

View Full Version : QLineedit Multiple Validation



csvivek
21st April 2008, 10:58
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

wysota
21st April 2008, 11:07
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.

csvivek
21st April 2008, 11:14
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..

wysota
21st April 2008, 11:55
Implement a subclass of QValidator?

csvivek
21st April 2008, 12:36
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.

mazurekwrc
21st April 2008, 12:48
http://doc.trolltech.com/4.3/qstring.html#at

csvivek
22nd April 2008, 10:17
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

aamer4yu
22nd April 2008, 10:26
Yes...
By QObject::sender () you can find the sender, cast it into proper object and you are done :)

csvivek
22nd April 2008, 10:59
thanks working fine!

wysota
22nd April 2008, 20:29
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.

csvivek
23rd April 2008, 12:55
i think that will be a bit complex!

wysota
23rd April 2008, 13:07
Complex? Like... 10 lines of code?

GuS
2nd May 2008, 19:33
Complex? Like... 10 lines of code?

Hi!

Could someone write a simple code of QLineEdit Validation? (maybe for 2 QLineEdits?).

Thanks in advance!!


Cheers.

wysota
4th May 2008, 20:04
You can validate lat/long with a regexp:


QRegExp rx("([0-8][0-9])|([0-9]0?)\s*[NS]\s+(1[0-7][0-9])|(180)|([0-9][0-9]?)\s*[EW]");