[PyQt] pyQT -python beginner question - combo box signal function call

karsten vennemann karsten at terragis.net
Fri Apr 22 09:07:36 BST 2011

I have a dynamic data entry from to which I am adding combo boxes on he fly using lists
  # here I add labels and combo boxes to the form from a list ..

# and then add a signal to trigger updating of the attribute in a table with the value selected in the combo box via the changeValue function

the function I have works but so is set to change always attribute column 2 (in bold)

    def changeValue(self, value):
        mc = self.canvas                  # the map cabavs uin QGIS
        layer = mc.currentLayer()      # a layer in QGIS
        ob = layer.selectedFeaturesIds()   
        layer.changeAttributeValue(int(ob[0]),2,value)  # Change value for colum 2 
How can I add one additional parameter to the function call form the combo box ?
Something like
QObject.connect(comboBoxNew[dropbox_counter],SIGNAL("currentIndexChanged(QString)"),self.changeValue(self, dropbox_counter))
    def changeValue(self, value, colum_id):
        mc = self.canvas         
        layer = mc.currentLayer()
        ob = layer.selectedFeaturesIds()
but with this I am getting
QObject.connect(comboBoxNew[dropbox_counter],SIGNAL("currentIndexChanged(QString)"),self.changeValue(self, dropbox_counter))
TypeError: arguments did not match any overloaded call:
  QObject.connect(QObject, SIGNAL(), QObject, SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 3 has unexpected type 'NoneType'
  QObject.connect(QObject, SIGNAL(), callable, Qt.ConnectionType=Qt.AutoConnection): argument 3 has unexpected type 'NoneType'
  QObject.connect(QObject, SIGNAL(), SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 2 has unexpected type 'str'
How can this be done correctly ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110422/91a62e86/attachment.html>

More information about the PyQt mailing list