[PyQt] signal editTextChanged
Kerri Reno
kreno at yumaed.org
Wed Jan 23 22:37:44 GMT 2008
I have a QComboBox, and I want the users to be able to edit the text, and I
want to know when the text has changed. I'm trying to use the signal
editTextChanged on the comboBox, but it doesn't seem to do anything.
Following is example code that illustrates what I mean. The line shows
'<Account Code>' and if you type over it, the updateText function should be
called and isn't. Any ideas what I'm doing wrong?
TIA,
Kerri
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
class acWidget(QWidget):
def __init__(self,parent,type='any',label=None):
QWidget.__init__(self,parent)
hLayout = QHBoxLayout(self)
hLayout.setSpacing(6)
if label:
lbl = QLabel()
lbl.setText(label)
hLayout.addWidget(lbl)
self.acCB = QComboBox(self)
self.acCB.setObjectName('acCB')
self.acCB.setDuplicatesEnabled(False)
self.acCB.addItem('<account code>')
self.acCB.setEditable(True)
hLayout.addWidget(self.acCB)
self.acCB.setEditable(True)
self.connect(self.acCB,
SIGNAL('editTextChanged(text)'),
self.updateText)
self.acCB.lineEdit().selectAll()
def updateText(self,text):
print 'got here'
if __name__ == '__main__':
app = QApplication(sys.argv)
form = QDialog()
layout = QVBoxLayout(form)
acWidget = acWidget(form,label='Account Code:')
layout.addWidget(acWidget)
form.setLayout(layout)
form.setMinimumWidth(400)
form.setMinimumHeight(200)
form.show()
app.exec_()
--
Yuma Educational Computer Consortium
Compass Development Team
Kerri Reno
kreno at yumaed.org (928) 502-4240
.·:*¨¨*:·. .·:*¨¨*:·. .·:*¨¨*:·.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080123/49a87981/attachment-0001.html
More information about the PyQt
mailing list