我有这个QSpinBox
类,它被修改为显示3位数(包括零)。在
class ThreeDigitSpinBox(QtGui.QSpinBox):
def __init__(self, *args):
QtGui.QSpinBox.__init__(self, *args)
def textFromValue(self, value):
return "%03d" % value
我的问题是,每次我选择并删除小部件上的现有值,并开始键入时,光标位置都会扰乱我的键输入。在
假设我刚刚删除了QSpinBox中的所有内容。然后我打算输入值“314”。在
(让我用“|”来表示光标)
当我输入“3”时,方框显示“003”,光标就在第一个0之后0 | 03。在
当我继续输入第二个数字“1”时,数字调整框显示“103”,光标就在第二个数字之后10 | 3“
由于光标的位置,我想要的数字“314”从未输入。相反,它在键入“314”的所有3位数字后显示“1043”。在
如何确保将光标放在正确的位置以便正确输入数字?在
我使用的是WindowsXPSP3和Python2.7.3(32位)
似乎可以使用基类QAbstractSpinBox,keyboardTracking的参数
如果设置为false,则在您按下enter键之前,它不会发出valueChanged信号,否则小部件将失去焦点。在
Qt文档中的说明:
pyqt docs在这里还是很没用的。在
相关问题 更多 >
编程相关推荐