QGIS Python call a method from another class

57 views Asked by At

In the QGIS plugin that I am developing, I have two classes

  • class emptydatabase, and
  • class Reservations.

From the Reservations class init method, I am trying to call a function within the emptyDatabase class.

class Reservations(QtWidgets.QDialog, FORM_CLASS):
    def __init__(self, parent=None):
        """Constructor."""
        super(BulkVectorExportDialog, self).__init__(parent)
        self.setupUi(self)           

        # initialise the empty database class object
        ed = emptydatabase() 
        self.btnEmpty.clicked.connect(ed, ed.empty(1))

The EmptyDatabase class

class emptydatabase:  

    def __init__(self):
        ....
        code here
    
    def empty(self, levels_to_empty): 

But when deploying the plugin using a zip file, I receive this error, and dont know what to make of it.

Couldn't load plugin 'Reservations_plugin' due to an error when calling its classFactory() method 

TypeError: Qt.ConnectionType expected, not 'emptydatabase' 
Traceback (most recent call last):
  File "D:\QGIS/apps/qgis-ltr/./python\qgis\utils.py", line 423, in _startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "C:\Users/name/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Reservations_plugin\__init__.py", line 36, in classFactory
    return BulkVectorExport(iface)
  File "C:\Users/name/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Reservations_plugin\bulkvectorexport.py", line 65, in __init__
    self.dlg = BulkVectorExportDialog()
  File "C:\Users/name/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Reservations_plugin\bulkvectorexport_dialog.py", line 75, in __init__
    self.btnEmpty.clicked.connect(ed, ed.empty(1))
TypeError: Qt.ConnectionType expected, not 'emptydatabase'
0

There are 0 answers