QDataWidgetMapper and QLineEdit with validator
-
Hello all,
I have form with several QLineEdit widgets managed by QDataWidgetMapper.
QLineEdit has assigned QRegExpValidator with pattern "[A-Z]{4}" - (four characters must be filled).
QDataWidgetMapper is set to manual submit policy.
But if I enter only two characters and call submit() on QDataWidgetMapper, it still save data into the model.Do I do something wrong way or how to ensure valid input?
Thanks in advance,
Jaroslav -
Hi Jaroslav
- I assume from your post that you want to actually match ANY four characters. If this is correct, then your expression should be "[A-Z | a-z]{4}" or else you'll only match CAPITALS.
- To solve your problem regarding the validation, you should implement something along the lines of:
@myLineEdit->setValidator(validator)
if(myLineEdit->hasAcceptableInput()) {
//capture data
}@Hope that helps!