Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyside Signal and Slots connect New Method

This code:

self.buttonOk.clicked(self.accept())
self.buttonCancel.clicked(self.reject())

Shows this error:

TypeError: native Qt signal is not callable

How do I connect buttonOk's clicked() signal to accept() Slot?

like image 376
vjdhama Avatar asked Feb 19 '23 05:02

vjdhama


1 Answers

There are a couple of things wrong with your code.

Firstly, you need to use the signal's connect() method to make the connection; and secondly, you need to pass in a callable object (i.e. no parens).

So your code needs to look like this:

self.buttonOk.clicked.connect(self.accept)
self.buttonCancel.clicked.connect(self.reject)

An overview of PySide's signal and slot support can be found here.

like image 103
ekhumoro Avatar answered Feb 21 '23 01:02

ekhumoro