2
When I want to connect a QPushButton
to an event, for example, I use a method and add it as event callback clicked.connect
For example:
def buildUi(self):
self.buttonSubmitText = QtWidgets.QPushButton("Enviar")
self.textChat = QtWidgets.QLineEdit()
self.buttonSubmitText.clicked.connect(self.onSubmitText)
def onSubmitText(self):
text = self.textChat.text()
message = create_message(self.selectedUser["id"], text)
formattedText = self._buildChatText(message)
self.viewChat.insertHtml(formattedText)
self.textChat.setText("")
But I’ve seen several examples on the internet where it’s added QtCore.pyqtSlot()
as decorator. That is, the code looks like this:
@QtCore.pyqtSlot()
def onSubmitText(self):
text = self.textChat.text()
message = create_message(self.selectedUser["id"], text)
formattedText = self._buildChatText(message)
self.viewChat.insertHtml(formattedText)
self.textChat.setText("")
I would like to know what is the impact of using or not using this decorator? It makes a difference?
It is mandatory to use it or not?
Very good. So I’ll use it on everyone.
– Wallace Maxters