[PyKDE] QValidator

Jim Bublitz jbublitz at nwinternet.com
Fri May 16 23:46:00 BST 2003


On Friday 16 May 2003 13:31, Kelley Reynolds wrote:
> I'm attempting to create a QValidator much like the built-in
> QIntValidator that has an optional maximum, minimum,
> configurable alert message, etc. Now, one of the things I'm
> having trouble with is controlling certain user actions in a
> form. The Validator works magically and perfectly if the user
> hits the 'enter' key, but not if they simply change focus.
> While this is fine for a maximum and making sure only
> numeral-related characters are typed in, it's not so good for
> the minimum. Other than using the lostFocus() signal of the
> QLineEdit(), (which has interesting issues when used in
> combination with a QMessageBox, not to mention the poor
> encapsulation that occurs when using lostFocus and a validator
> which should do all of this anyway), is there a way to make
> ensure validation if a user does something other than hit the
> 'enter' key?

Have you tried connecting to the 'textChanged' signal?

Jim




More information about the PyQt mailing list