I have a set of QLineEdits
that are supposed to accept double values within a certain range, (e.g., -15 to 15).
I have something along these lines when
I spent almost a day trying to make QDoubleValidator
work with reasonable user feedback when checking for acceptable range of QLineEdit
input. My attempts to use Qt prescribed validator::fixup()
turned out to be a waste of time. Earlier answers in this thread are much more useful but still have shortcomings. In the end I opted for a different and simpler approach.
QLineEdit
with QDoubleValidator
which performs no range checking. QLineEdit
editingFinished
signal do range checking and if necessary reset of QLineEdit
text.This approach disallows typing of illegal characters, takes care of localization and corrects values outside of desired range.
Works well for me.