[SOLVED] Validate inputs using QValidator class
-
wrote on 16 Aug 2015, 17:09 last edited by sachi
Hello I am developing application which have many forms. I need to validate user input. I figure out QValidator is good solution for this. but I have many classes which has different forms. It is possible to use one QValidator class to validate all forms. Or I have to create QValidator object for every single input.
-
Hi
QValidator is (often) per Input
but you can share one validator with more than one input
if they have the same rules for acceptable input.But you cannot use one validator for a whole form since it has no way of knowing
which rules for each input.The easiest way to set validation up, really depends on what types of input you have and how different they are.
-
wrote on 16 Aug 2015, 18:21 last edited by
I have usually text field for name which mush not null, and phone number and email. how i should start?
-
Hi
The validator work while user writes something so its hard to make it check for empty string so
maybe just check that on "OK".For phone and email, you can use RegExpValidator.
Please see
http://stackoverflow.com/questions/9101887/how-to-validate-email-address-using-qregexpIts a bit complex to start with but once you get it up and running, you can just reuse the validator where needed.
-
wrote on 16 Aug 2015, 19:08 last edited by
Thank you for your help
1/5