Results 1 to 6 of 6

Thread: Can't get the QRegExp I need

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2014
    Posts
    82
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    10

    Default Can't get the QRegExp I need

    Hi! I'm trying to get a RegExp to validate the info of a lineedit which accepts 3 numbers followed by DG and then 4 numbers more and a fifth optional.
    For example, valid will be: 123DG1234 or 111DG2222
    Invalid ones would be: 111DG or 111DDD or 111 or 111DG222

    I have the next but when I try to write, I cant. I doesn't let me write a number or letter or anything. I tried using other RegExp I have for other LineEdits and it works fine so I suppose thta the problem is in the setPattern.

    Qt Code:
    1. QRegExp rx9;
    2. rx9.setPattern("[1-9]\\d{3}][DG]\\d{4,5}");
    3. QValidator *validator9 = new QRegExpValidator(rx9, this);
    4. myLineEdit->setValidator(validator9);
    To copy to clipboard, switch view to plain text mode 

    EDIT: Andif I put
    Qt Code:
    1. rx9.setPattern("[1-9]{3}[DG][1-9]{4}");
    To copy to clipboard, switch view to plain text mode 
    It just allows me to write 123D and that's all

    Thank you so much
    Last edited by roseicollis; 30th March 2015 at 12:11.

Similar Threads

  1. Please help on QRegExp
    By lni in forum Qt Programming
    Replies: 6
    Last Post: 25th September 2011, 08:42
  2. QRegExp Help
    By ToddAtWSU in forum Qt Programming
    Replies: 6
    Last Post: 16th November 2010, 16:35
  3. QRegExp
    By tebessum in forum Qt Programming
    Replies: 1
    Last Post: 3rd August 2008, 19:44
  4. QRegExp help
    By Lele in forum Qt Programming
    Replies: 2
    Last Post: 8th February 2008, 11:07
  5. QRegExp Help
    By Ahmad in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2007, 01:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.