Issue
I am attempting to create a custom function for when the "OK" button is clicked in a custom modal.
class Second(QDialog):
def __init__(self, parent=None):
super(Second, self).__init__(parent)
def funct():
print("This is a test")
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel, self)
buttonBox.rejected.connect(self.reject)
buttonBox.accepted.connect(self.funct)
I am able to use both self.reject() and self.accept() without any complications, but when I attempt to use self.funct(), I receive the error message in the title. None of the suggestions from similar questions seemed to help. Is it something with the QDialogButtonBox in particular?
Solution
The funct
function is a nested function so it is not part of the Second
class so it is inappropriate to use the instance (self
) to access it, what you must do is access directly, for it uses:
buttonBox.accepted.connect(funct)
Answered By - eyllanesc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.