[PyQt] QSpinBox and setLineEdit
Mpi
mpi at comxnet.dk
Fri Jan 30 09:22:57 GMT 2009
Hi,
You can set a custom line edit on a spinbox using the method setLineEdit().
Suppose I implement a class that inherits from QLineEdit and overwirite the
'setText' method, you'd expect that pressing the arrow button on the spinbox
would trigger a call to your custom setText method. I can't get this to work
though. Code that reproduces the behavior is attched below,
Best regards,
Mads Ipsen
import sys
from PyQt4 import QtCore, QtGui
class LineEdit(QtGui.QLineEdit):
def __init__(self, parent=None):
QtGui.QLineEdit.__init__(self, parent)
def setText(self, text):
print 'LineEdit', text
QtGui.QLineEdit.setText(self, text)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
widget = QtGui.QSpinBox()
line_edit = LineEdit()
widget.setLineEdit(line_edit)
widget.show()
sys.exit(app.exec_())
More information about the PyQt
mailing list