[Qt-interest] QValidator::validate() and QLineEdit ... when is it called?
Robert Hairgrove
evorgriahr at hispeed.ch
Sat Feb 5 00:10:45 CET 2011
I am having a problem with unwanted recursion in my custom validator's
validate() function. Might be a simple (stupid) bug on my part, but I
think the documentation is somewhat unclear on this.
According to the documentation, as I understand it, the validation
should only take place after the editing finishes. But as soon as I type
one character, it is called immediately, and seemingly unendlessly at
that.
The purpose is to check for an existing file after the user enters a
path manually. I have set up a browse button which works successfully to
find a file, but sometimes it is quicker just to change one or two
characters in an existing file name without going through the open file
dialog. 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.
Can I use QValidator (i.e. subclass it) for this?
More information about the Qt-interest-old
mailing list