Results 1 to 4 of 4

Thread: How to set QLineEdit to accept only ASCII...

  1. #1
    Join Date
    Jun 2008
    Location
    Rome, Italy
    Posts
    95
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default How to set QLineEdit to accept only ASCII...

    Hi to all,
    I'd like to set a QLineEdit object to accept only ASCII chars without use inputMask because I should set a 'N' for 128 times(buffer lenght). Is there a simple way to do that?
    Thanks.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to set QLineEdit to accept only ASCII...

    Use QRegExpValidator.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to set QLineEdit to accept only ASCII...

    The 'N' validator character doesn't meet your requirement anyway. For example, it will not allow punctuation like comma, parentheses, semi-colon etc., which are clearly ASCII characters.

  4. #4
    Join Date
    Jun 2008
    Location
    Rome, Italy
    Posts
    95
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to set QLineEdit to accept only ASCII...

    Thanks, I'll try QLineEdit->text().toASCII(); function.

Similar Threads

  1. Masking QLineEdit to accept white space.
    By savaliya_ambani in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 20th February 2011, 11:45
  2. Replies: 1
    Last Post: 12th October 2010, 22:20
  3. accept() and reject() slots
    By poporacer in forum Newbie
    Replies: 3
    Last Post: 19th August 2010, 01:07
  4. ASCII to int and int to ASCII
    By askbapi in forum Newbie
    Replies: 2
    Last Post: 31st March 2010, 22:36
  5. ASCII to PDF
    By jaca in forum Newbie
    Replies: 3
    Last Post: 19th September 2009, 23:51

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.