The specification of the options 'top' and 'bottom' seems to have a strange behavior. The following answered question gave some useful insights, but does not cure everything.
With the code :
import sys
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
app = QApplication(sys.argv)
input = QLineEdit()
input.setValidator(QDoubleValidator(0.00,10.00,5,notation=QDoubleValidator.StandardNotation))
input.show()
sys.exit(app.exec_())
The input box accepts any number below 100, but I would expect only numbers below 10 ... For example, 99.55656 is accepted just fine...
What do I miss ?
CodePudding user response:
In your example, the line-edit does not literally accept the value 99.55656
. This can be confirmed by calling its hasAcceptableInput method, which returns False
.
The validator is allowing the value to be entered, because doing so produces a valid Intermediate state. According to the docs, this can happen "if it is likely that a little more editing will make the input acceptable". So in the specific case of 99.55656
, deleting a 9
would produce a valid Acceptable state. This would seem to imply that "a little more editing" should be taken to mean adding or removing a single character (where the notation is StandardNotation
).