2

I am trying to migrate a plugin. I have these two lines:

QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Configuration.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Configuration.reject)

I thought after looking into some examples that in PyQt5 the lines should read:

self.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Configuration.accept)
self.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Configuration.reject)

but it just throws the error

AttributeError: 'ConfigurationDialog' object has no attribute 'QObject'

This is confusing because ConfigurationDialog is not found in this py script. ConfigurationDialog is a class in another script but nowhere in it does it make reference to QObject. Can I get some clarification on what where I am going wrong?

0

2 Answers 2

5

With this documentation about PyQt5 signals, try this :

self.buttonBox.accepted.connect(Configuration.accept)
self.buttonBox.rejected.connect(Configuration.reject)
1
  • Thank you; I really need to do a python3 and pyQt5 course I would never have gotten that.
    – MrKingsley
    Commented Apr 2, 2019 at 13:19
1

I can't really tell you why the error message occurs, because I can't see your full code. But to solve your problem, try creating the Signal/Slot connection like this:

self.buttonBox.accepted.connect(Configuration.accept)
self.buttonBox.rejected.connect(Configuration.reject)

I hope this helps

Not the answer you're looking for? Browse other questions tagged or ask your own question.