Results 1 to 13 of 13

Thread: How to force capital letters in input field?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to force capital letters in input field?

    Just please tell us why you didn't want to use the validator approach. You could have written about 5-10 lines of code to do what you wanted but you decided to write many more lines of code that don't do what you wanted (see my point on pasting text into the box). If the user wants to type in capital letters then it will be easier for him to enable caps lock than to check some boxes on your ui.
    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.


  2. #2
    Join Date
    Aug 2009
    Posts
    92
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to force capital letters in input field?

    I've used the same system: sending a signal when a key has been pressed.

    I need to capitalise all the user inputs but not what the gui automatically inserts, so a signal is much more efficient than a validator.

    And it's 10 lines

    Qt Code:
    1. protected:
    2. void keyPressEvent(QKeyEvent* e)
    3. {
    4. if (e->key() >= Qt::Key_A && e->key() <= Qt::Key_Z)
    5. emit KeyPressed(e->text().toUpper().at(0));
    6. else
    7. QLineEdit::keyPressEvent(e);
    8. }
    9. signals:
    10. void KeyPressed(const QChar&);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Twisted Letters in Vertical Axis Title
    By DrunkenUFOPilot in forum Qwt
    Replies: 6
    Last Post: 24th January 2012, 23:56
  2. QregExp: matching accented letters
    By bred in forum Qt Programming
    Replies: 0
    Last Post: 4th January 2011, 10:48
  3. A collection of letters and numbers
    By NewLegend in forum Qt Programming
    Replies: 8
    Last Post: 8th September 2010, 19:44
  4. Replies: 11
    Last Post: 11th July 2010, 21:44
  5. Reading umlaut letters from sqlite database
    By Djony in forum Qt Programming
    Replies: 11
    Last Post: 17th November 2006, 10:30

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.