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. QRegExpValidator exact number of characters
Forum Updated to NodeBB v4.3 + New Features

QRegExpValidator exact number of characters

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 776 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.
  • R Offline
    R Offline
    republicca
    wrote on last edited by
    #1

    Hello,
    I'm implementing a series of QLineEdits which I have to validate. In one case, I only want to permit exactly 8 characters no more no les. Right now I have this:

    @
    lineEdit->setValidator(new QRegExpValidator(QRegExp("([a-zA-Z0-9]){8}"), this));
    @

    But it also allowds expressions of less than 8. Any suggestions?
    Thank you!!

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      How do you intend to put the characters into the line edif when the validator would block input of less than 8 chars? I think your current solution is fine. You just need to check it later for correctnes (for example, when edit is finished, or user clicks some button).

      (Z(:^

      1 Reply Last reply
      0
      • R Offline
        R Offline
        republicca
        wrote on last edited by
        #3

        You are totally right. Thank you!

        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