EditingFinished signal gets emitted on every key press in QLineEdit when QCompleter is used (Qt 4.8 in PySide 1.1.0), not just when pressing enter or
I am trying to build a QLineEdit with a custom QCompleter. I need a custom QCompleter so I can hook up a more efficient search engine ... I mocked this up in the sample code below (res = ...) to reproduce the issue.
The trouble here is that when the pop up completion list is refreshed (on entering the second character and every character after that) editingFinished is emitted.
Everything else works just fine. So how do I prevent the extra editingFinished signals?
This snippet is partially based on http://john.nachtimwald.com/2009/07/04/qcompleter-and-comma-separated-tags/
from PySide import QtGui
from PySide.QtGui import QCompleter, QLineEdit, QApplication
def init(self, parent):
QCompleter.init(self, , parent)
def update(self, completion_prefix): res = [str(i) for i in range(100000)] model = QtGui.QStringListModel(res) self.setModel(model) self.setCompletionPrefix(completion_prefix) if completion_prefix.strip() != '': self.complete()
app = QApplication(sys.argv)
editor = QLineEdit()
completer = CustomCompleter(editor)
if name == 'main':
I might add it's line 15
that triggers the emission of the editingFinished signal.
While I can hack around it - it's ugly - is there a better way?