[GIS] PyQt4 pushbutton not connecting for the QGIS plugin

pyqtpythonqgiswidget

I'm trying to display information in a text browser with the push of a button in my QGIS plugin. The .ui is created using PyQt4 (button's object name is calcConso). No error message, but the button isn't connecting. The button simply displays values returned by my stats function, but the function itself isn't actually called anywhere. If it should be, I don't see where yet.

Any ideas what's missing?

def initGui(self):
# connect button to calculation function
    QObject.connect(self.dlg.ui.calcConso, SIGNAL("clicked()"), self.buttonClicked)

def buttonClicked(self):
    global stats, values
    self.dlg.clearTextBrowser()
    self.dlg.setTextBrowser( str(stats, values) )

def stats(self):
    global stats, values
    ...
    return stats, values

in a separate dialog class i've defined clearTextBrowser() and setTextBrowser(), which is imported.

def setTextBrowser(self, output):
    self.ui.txtFeedback.setText(output)

def clearTextBrowser(self):
    self.ui.txtFeedback.clear()

Best Answer

To test your connection:

from PyQt4.QtGui import QMessageBox
...
result = QObject.connect(self.dlg.ui.calcConso, SIGNAL("clicked()"), self.buttonClicked)
QMessageBox.information(None, 'Connection result', "Connect returned %s" % result)