PDA

View Full Version : QLineEdit & QValidator - umm...



matheww
20th June 2007, 05:02
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)..

:eek:

jpn
20th June 2007, 12:09
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.

Michiel
20th June 2007, 13:06
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.

matheww
20th June 2007, 21:40
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..