I've been looking for a way of subclassing QPushButton, so I can connect 'clicked' signal when constructing new button, like:
Btn = CustomButtonClass('Text', clicked='lambda: self.func(par)')
So far - without any success.
I guess the thing is to pass correct parameters to init() of CustomButtonClass, but have no idea what, and why.
What I've got:
class CustomButtonClass(QtGui.QPushButton):
def __init__(self, text, parent=None):
super().__init__()
I also noticed that:
Btn.clicked.connect(lambda: self.func(par))
Also doesn't work.
Do I have to override QPushButton's mouseReleaseEvent or construct custom signal to be able to complete my task?