I have a custom form for editting feature attributes. However, I can't seem to correctly disconnect and reconnect certain bindings. The init code is below and should work for any simple QT widget with buttons.
It doesn't throw an error. The OK button is disconnected from the original connect that QGIS assigns. But it does not reconnect to the validate function.
Can anyone point me in the direction of the mistake here?
from PyQt4.QtCore import *
from PyQt4.QtGui import *
# QGIS passes in the dialog, he layer_id and the feature_id
def form_open(myDialog,layer_id,feature_id):
# QGIS passes in the dialog, he layer_id and the feature_id
# I send all this to be handled by its own class. So I can use
#'self' and avoid having to use globals...
return MyClass(myDialog,layer_id,feature_id)
class MyClass(QDialog):
def __init__(self,myDialog,layer_id,feature_id):
self.ui = myDialog
self.buttonBox = self.ui.findChild(QDialogButtonBox,"buttonBox")
# The problem is here...
self.buttonBox.accepted.disconnect(self.ui.accept)
self.buttonBox.accepted.connect(self.validate)
def validate(self):
msgBox = QMessageBox()
msgBox.setText("I validate here...")
msgBox.exec_()