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

Robert Hairgrove evorgriahr at hispeed.ch
Sat Feb 5 12:29:48 CET 2011


On Fri, 2011-02-04 at 18:33 -0500, K. Frank wrote:
> 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.

Thank you ... this is a good idea. Now I have put my own validation code
in the handler for the editingFinished() signal, and the user has the
option to restore the old value or keep the typed entry.




More information about the Qt-interest-old mailing list