Pourquoi Événement keyPress en PyQt ne fonctionne pas pour la touche Enter?
Pourquoi, lorsque j'appuie sur Entrée, le keyPressEvent
méthode de ne pas faire ce dont j'ai besoin? Il se déplace le curseur sur une nouvelle ligne.
class TextArea(QTextEdit):
def __init__(self, parent):
super().__init__(parent=parent)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.show()
def SLOT_SendMsg(self):
return lambda: self.get_and_send()
def get_and_send(self):
text = self.toPlainText()
self.clear()
get_connect(text)
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Enter:
self.get_and_send()
else:
super().keyPressEvent(event)
OriginalL'auteur Ilya Glushchenko | 2013-03-07
Vous devez vous connecter pour publier un commentaire.
Qt.Key_Enter
est l'Entrée située sur le clavier:Utilisation:
OriginalL'auteur warvariuc