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,

  • Hi Jaroslav

    1. 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.
    2. To solve your problem regarding the validation, you should implement something along the lines of:

    if(myLineEdit->hasAcceptableInput()) {
    //capture data

    Hope that helps!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.