python - How can i create my own SIGNAL and channel it to a SLOT? -


On a mouse click on the QLineEdit widget, I want to clear my content completely.

QLineEdit does not have any indication to detect mouse clicks, so I've written the class below for installEventFilter.

But please suggest that I can channel it to "SLOT" ("clear"). Suggestions where I'm missing something -

  square mouse click (QObject): def __init __ (self, parent = none): super (mouse click, self) .__ init __ (Parent) Def eventFilter: (event.type () == QEvent.MouseButtonPress): self.emit (Signal ("A"), "A") False class form (QDialog) return: Def __init __ (self, parent = none): super (form, self) .__ init __ (parent) self.UsrName = QLineEdit ("user name") self.filter = mouse click () self.UsrName.installEventFilter (Self.filter) self.connect (self.UsrName, Signal ("AA"), S Do not use event filter  ("clear"))  

>

  self.UsrName = QLineEdit ("user name") self.UsrName.mousePressEvent = Lambda event: self.UsrName.clear ()   

This is the same every time the user clicks the line editing, it will be cleared.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -