Results 1 to 4 of 4

Thread: QLineEdit & QValidator - umm...

  1. #1
    Join Date
    Jun 2007
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Wink QLineEdit & QValidator - umm...

    Hi all..

    I find this a bit strange, i have a (number of) QLineEdit's which have a QValidator set (I have subclassed it to lookup a database). If the QValidator returns invalid or Intermediate the user is still able to "Tab" out of the QLineEdit, I really need to stop them doing this - really I would have expected that if the Validator is not valid that the user has to keep edit the field until they input a correct value! (isnt that what validation is all about)..

    Any ideas on howto stop a user from leaving the edit until they have entered something valid? I have not yet looked at sub-classing qlineedit, but may have to (dont want to as I have multiple of these on dialogs designed with designer)..


  2. #2
    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 & QValidator - umm...

    Forcing focus to a certain widget might not be a good idea (users of the application might get annoyed). Instead, consider preventing the ways for proceeding by disabling corresponding actions/buttons or so.
    J-P Nurmi

  3. #3
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QLineEdit & QValidator - umm...

    Agreed.

    However, if you choose to force focus anyway, and subclassing QLineEdit is the only way to do that, you can still use Designer quite easily. Simply promote the line-edit fields to custom widgets from within Designer.
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

  4. #4
    Join Date
    Jun 2007
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QLineEdit & QValidator - umm...

    I am looking at subclassing now, have to figure a way of preventing focus from being lost from the lineedit when the edit is invalid..

    btw, i am the main user of the application so I get to choose how it works (nice way to be).. also in experence with users, its best to prevent them from moving on if they havent entered the right data, it seems to cause less grief later on..

Similar Threads

  1. QLineEdit lost focus
    By codebehind in forum Newbie
    Replies: 5
    Last Post: 4th May 2007, 16:02
  2. Problem with QLineEdit and setText
    By Elmo23x in forum Qt Programming
    Replies: 8
    Last Post: 12th April 2007, 12:35
  3. QAction shortcuts from QLineEdit
    By discostu in forum Qt Programming
    Replies: 3
    Last Post: 4th March 2007, 15:43
  4. Replies: 1
    Last Post: 26th November 2006, 09:32
  5. a box around QLineEdit?
    By GreyGeek in forum Qt Tools
    Replies: 13
    Last Post: 8th February 2006, 15:40

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.