[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 ..
self.dlg.ui.streamEditCustomFormLayout.addWidget(comboBoxNewLabel[dropbox_counter])
self.dlg.ui.streamEditCustomFormLayout.addWidget(comboBoxNew[dropbox_counter])

# 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
QObject.connect(comboBoxNew[dropbox_counter],SIGNAL("currentIndexChanged(QString)"),self.changeValue)

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()
        layer.changeAttributeValue(int(ob[0]),colum_id,value)
 
 
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 ?
Karsten
-------------- 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