Using Qt Designer created a Push Button, then code:
# import ...
class Test:
def __init__(self):
qfile = QFile("test.ui")
qfile.open(QFile.ReadOnly)
qfile.close()
self.ui = QUiLoader().load(qfile)
self.ui.pushButton.clicked.connect(self.buttonClicked)
def buttonClicked(self):
print(self.ui.sender().text())
app = QApplication([])
test = Test()
test.ui.show()
app.exec_()
When I clicked the button, getting error message:
AttributeError: 'NoneType' object has no attribute 'text'
How can I get the button text?