我创建了一个QWidget对象,其中有一些lineEdits,我打算在其中添加一些约束,所以我实现QDoubleValidator objects.Following是我的代码中的相关部分。
self.inductance = QLineEdit()
self.inductance.setValidator(QDoubleValidator(0.99,99.99,1))
我会写123,但不能写123.45
发布于 2022-07-20 08:02:41
您需要将"QDoubleValidator(0.99,99.99,1)“更改为"QDoubleValidator(0.99,99.99,2)”,如下所示:
from PyQt5.QtWidgets import QLineEdit
from PyQt5.QtGui import QDoubleValidator
self.inductance = QLineEdit()
self.inductance.setValidator(QDoubleValidator(0.99, 99.99, 2))
https://stackoverflow.com/questions/70724720
复制相似问题