Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
5.10.0
-
None
Description
I am using a combination of QLineEdit+QCompleter and QItemView to provide the user with a list of items, and a filter input for searching specific items. This works great, except that the completer only updates its model (completionModel) when the filter narrows. In the case the filter widens (e.g., backspace is pressed), this is ignored.
Here is my workaround:
/* Implement behavior such as updating the filter also when a character is removed. * It seems by default, QCompleter only updates when new characters are added. */ QString lastText; connect(protSearch, &QLineEdit::textEdited, [cpl, lastText] (const QString &text) mutable { if (text.length() < lastText.length()) { cpl->setCompletionPrefix(text); } lastText = text; });
It would be great if QCompleter would have a property that toggles the behavior between
(a) current, only update when the filter narrows / new characters are added
(b) new, also update in other cases
It could be named updateStrategy ('always', 'forward').