1

This question already has an answer here:

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?

marked as duplicate by Andre Silva, HDunn, Hornbydd, whyzar, LaughU Apr 4 at 6:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3

With this documentation about PyQt5 signals, try this :

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

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.