[PyQt] QSpinBox does not recognize returnPressed event
hpj at urpla.net
Wed May 11 14:36:19 BST 2011
On Wednesday 11 May 2011, 11:13:24 Adrian Casey wrote:
> I want to connect the returnPressed() event to a QSpinBox widget but
> it is not working. I use the same approach with a QComboBox and it
> works. I'm using Qt 4.7.0 and PyQt on Kubuntu 10.10.
> Here is a simple form containing a combobox and a spinbox. Only the
> combobox registers the returnPressed event.
> Can anyone tell me why the spinbox does not see the returnPressed
From a cursory look, I would call this a Qt bug. Obviously, they handle
the keyEvent for the return key in some way (by selecting the text),
but forget to emit the signal, nor call the QLineEdit base class event
A look into the Qt source would clarify things and often gives an idea
for a work around. As a starter, you could install some kind of event
filter on the lineEdit widget and emit the signal yourself.
> # simple.py
> import sys
> from PyQt4 import QtGui
> def do_it():
> print 'Return pressed!'
> app = QtGui.QApplication(sys.argv)
> widget = QtGui.QWidget()
> widget.resize(250, 150)
> widget.setWindowTitle('Signal Test')
> layout = QtGui.QBoxLayout(2, widget)
> cb = QtGui.QComboBox(widget)
> sb = QtGui.QSpinBox(widget)
> PyQt mailing list PyQt at riverbankcomputing.com
More information about the PyQt