Issue
QLineEdit
triggers a signal on .clear()
or .setText()
method.
So every time those methods are used to stop LineEdit from emitting the signal I need to .blockSignals(True)
and then .blockSignals(False)
.
I wonder if there is a way around it?
from PyQt4 import QtCore, QtGui
app = QtGui.QApplication([])
class LineEdit(QtGui.QLineEdit):
def __init__(self, *args, **kwargs):
super(LineEdit, self).__init__()
self.setText('Some Text')
self.textChanged.connect(self.printMessage)
self.show()
def printMessage(self):
print 'Triggered!'
line=LineEdit()
line.clear()
sys.exit(app.exec_())
Solution
Have you considered QLineEdit::textEdited
? It doesn't emit signals when the text is changed programatically.
Answered By - James
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.