[Interest] QLineEdit upper case

Till Oliver Knoll till.oliver.knoll at gmail.com
Fri Aug 8 17:42:51 CEST 2014

Am 08.08.2014 um 16:54 schrieb pmqt71 <pmqt71 at gmail.com>:

> Hi Bo,
> as I said, some controls already have a validator so I can't replace it.

So basically your problem is: "How to chain together (combine) several Validators!"

E.g. you have one Validator which only accepts the characters 'a', 'b' and 'c' while at the same time - in certain text input fields - you also want to make sure that all characters are UPPER case.

Maybe you could reach that goal with inheritance: e.g. the base class would validate the acceptable characters, whereas the derived class would - after having called the parent's validation methods and once they pass in an acceptable state - then validate those characters.

Or (probably better) you could come up with a "ChainValidator" class where you could add any kind of QValidator, and the "ChainValidator" would simply call those validators in order, until they all pass or it would stop as soon as a QValidator would end up in an Invalid state (+ think about it what it means when you get an Intermediate state in the middle, or how to deal with "fixup" etc. - at a quick glance I do not see any conceptual obstackles here).

Off course certain combinations of Validators wouldn't make sense, e.g. chaining a QFloatValidator with a QIntValidator. How to solve/avoid that is left as an exercise for the reader ;)

Just an idea anyway...


More information about the Interest mailing list