I have a large amount of generated QLineEdits that I want to put numerical range validation on. QIntValidator provides this for a single range, but I want to make it possible to validate on an arbitrary number of discontinuous ranges as read from an XML file. For example, I may want the lineEdit to be able to take integers in the range of (0-50), (100-200) and (1000-1400), but not the ranges in between those.

I had the idea of reimplementing QIntValidator to contain a list of QIntValidators for each range I want to add to it, but looking at the documentation further I don't think that will work very well.

I guess the other option would be parsing the xml myself and constructing regular expressions at run time for use in QRegExpValidator, but that seems excessive in terms of both time and effort and performance for the payoff.

This would be simple if Qt allowed multiple validators to be put on one object, but if you set a more than one validator the second one replaces the first one.

Thanks in advance for any ideas.