Results 1 to 20 of 30

Thread: QLineEdit set min max range?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #19
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QLineEdit set min max range?

    The focus out event could look for example something like this:
    Qt Code:
    1. void MyLineEdit::focusOutEvent(QFocusEvent* event)
    2. {
    3. // check validator state
    4. int pos = 0;
    5. QValidator::State state = validator()->validate(text(), pos);
    6.  
    7. if (state == QValidator::Intermediate)
    8. {
    9. // keep focus if intermediate
    10. setFocus();
    11. }
    12. else
    13. {
    14. // otherwise call base class implementation and let it
    15. // handle focus out actions (so cursor stops blinking etc.)
    16. QLineEdit::focusOutEvent(event);
    17. }
    18. }
    To copy to clipboard, switch view to plain text mode 

    If you have difficulties in subclassing QLineEdit, I suggest you to switch back to your favourite C++ book and learn the secrects of inheritance..
    J-P Nurmi

  2. The following user says thank you to jpn for this useful post:

    whitefurrows (10th June 2006)

Similar Threads

  1. Replies: 10
    Last Post: 12th February 2009, 07:23
  2. QLineEdit
    By rick_st3 in forum Newbie
    Replies: 1
    Last Post: 14th June 2008, 09:05
  3. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 15:13
  4. QValidator, regular expressions and QLineEdit
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 01:25
  5. Qt and MySQL Database Connection
    By shamik in forum Qt Programming
    Replies: 41
    Last Post: 6th October 2006, 12: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.