Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDataWidgetMapper and QLineEdit with validator
Forum Updated to NodeBB v4.3 + New Features

QDataWidgetMapper and QLineEdit with validator

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jarda
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goblincoding
      wrote on last edited by
      #2

      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:
        @myLineEdit->setValidator(validator)

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

      Hope that helps!

      http://www.goblincoding.com

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved