[Qt-interest] QValidator::validate() and QLineEdit ... when is it called?

K. Frank kfrank29.c at gmail.com
Sat Feb 5 00:33:07 CET 2011


Hello Robert!

I do not have an answer to your question, but I do have a
user-interface suggestion.

On Fri, Feb 4, 2011 at 6:10 PM, Robert Hairgrove <evorgriahr at hispeed.ch> wrote:
> I am having a problem with unwanted recursion in my custom validator's
> validate() function.
> ...
> However, checking should only occur after the user finishes
> editing (i.e. when the editingFinished() signal would normally be
> emitted). My validator class keeps record of the previous value (if any)
> and if the new value is invalid, it should reset the line edit control's
> text to whatever it was before by assigning the non-const argument
> references passed to the validate() function.

It might be preferable _not_ to erase or overwrite what the user
has typed in.

Let's say that the preloaded file name is "file0123456789.txt"
and the user needs to edit it to read "file987654321.txt", but
inadvertently skips the '6', "file98754321.txt".  In your scheme,
the user cannot see what he incorrectly typed, gets no detailed
feedback about what might be wrong (other than that there is
no exact match), and has to repeat the entire process of editing
the file name.

It may not seem like much, but these kinds of "lossy" user
interfaces that forget what I've done and make me repeat my
work drive me nuts.

Just a thought.


Good luck with your original question.


K. Frank



More information about the Qt-interest-old mailing list