From the Qt docs:
fixup() is provided for validators that can repair some user errors. The default implementation does nothing. QLineEdit, for example, will call fixup() if the user presses Enter (or Return) and the content is not currently valid. This allows the fixup() function the opportunity of performing some magic to make an Invalid string Acceptable.
http://qt-project.org/doc/qt-4.8/qvalidator.html
So yes, if your 'string cleaning' is an attempt to correct the user's input, fixup
should be the correct place to do this.
EDIT:
This should capitalize the first four characters:
def validate(self, s, pos):
print 'validate(): ', type(s), type(pos), s, pos
n = min(4,s.count())
if s.left(n).compare(s.left(n).toUpper()):
return (QtGui.QValidator.Intermediate, pos)
else:
return (QtGui.QValidator.Acceptable, pos)
def fixup(self, s):
n = min(4, s.count())
s.replace(0, n, s.left(n).toUpper())