Results 1 to 2 of 2

Thread: Line edit accept only alphanumeric characters, dash and underscore

  1. #1
    Join Date
    Jun 2013
    Posts
    22
    Thanks
    1
    Qt products
    Qt5

    Default Line edit accept only alphanumeric characters, dash and underscore

    I'm looking for the way to limit line edit to accept only alphanumeric characters, dash and underscore (in whole line could be only one dash and one underscore), without spaces. I was looking at RegExp, but then I left this option, because I found some blog post which is explaining that RegExp is really slow. Now I don't know what is best way to limit line edit, so the output would be like I want.

    What do you recommend me?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Line edit accept only alphanumeric characters, dash and underscore

    Unless you are going to be filling a few thousand fields per second, you can safely use QRegExpValidator. Otherwise subclass QValidator and do the validation yourself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QTableView line edit clears the text on edit
    By PlasticJesus in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2015, 19:06
  2. Something like putting dash every new line in QTextEdit
    By kornicameister in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2011, 23:08
  3. Replies: 3
    Last Post: 26th August 2010, 08:57
  4. Displaying all characters in text edit
    By chadkeck in forum Qt Programming
    Replies: 1
    Last Post: 17th September 2008, 01:48
  5. Replies: 8
    Last Post: 15th May 2007, 09:21

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.