Reputation: 15049
There are signals valueChanged() and editingFinished(), but I need perform my action only when key enter is pressed.
Is there any solution without reimplementing event handler?
I need to change focus to the next spinbox on pressed enter key. Any idea?
Upvotes: 8
Views: 4839
Reputation: 837
You can access the underlying QLineEdit
object which emits the desired returnPressed()
signal:
spin_box = QSpinBox()
spin_box.lineEdit().returnPressed.connect(self.spinBoxReturnPressed)
def spinBoxReturnPressed():
...
Upvotes: 3
Reputation: 5546
Use setKeyboardTracking(False)
If keyboard tracking is disabled, the spinbox doesn't emit the valueChanged() signal while typing. It emits the signal later, when the return key is pressed, when keyboard focus is lost, or when other spinbox functionality is used, e.g. pressing an arrow key.
Upvotes: 9