Results 1 to 7 of 7

Thread: Regular Expression for QDate [YYYY/MM/DD] format

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Jun 2019
    Posts
    2
    Qt products
    Qt5 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Windows Android Maemo/MeeGo

    Default Re: Regular Expression for QDate [YYYY/MM/DD] format

    Quote Originally Posted by jacek View Post
    The code below worked for this format, d/M/yyyy i.e 1/12/2019

    Qt Code:
    1. QRegExp R_date("([1-9]|[12][0-9]|3[01]{1,2})/([1-9]|[12]{1,2})/(19[0-9][0-9]|20[0-9][0-9])");
    2. QRegExpValidator *valida = new QRegExpValidator(R_date, this);
    3. ui->lineEdit->setValidator(valida);
    To copy to clipboard, switch view to plain text mode 

    The code below worked for this format, dd/MM/yyyy i.e 01/12/2019, 02/03/2019

    Qt Code:
    1. QRegExp R_date("(0[1-9]|[12][0-9]|3[01]{1,2})/(0[1-9]|[12]{1,2})/(19[0-9][0-9]|20[0-9][0-9])");
    2. QRegExpValidator *valida = new QRegExpValidator(R_date, this);
    3. ui->lineEdit->setValidator(valida);
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 3rd August 2019 at 22:41. Reason: missing [code] tags

Similar Threads

  1. Some very weird compilation warnings
    By MarkoSan in forum Qt Programming
    Replies: 21
    Last Post: 23rd January 2008, 16:48

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.