Preventing QCompleter from modifying the content during selection
-
Hi folks,
I'm trying to prevent a QCompleter from modifying the content of the text box while the user is cycling through the options.
Ideally I want it to just send a signal of some sort when the user clicks or presses enter on an item. Is this possible?
My setup is as follows:
auto* lineEdit = new QLineEdit(parent); auto* completerListView = new QListView(parent); auto* completer = new QCompleter(parent); completer->setPopup(completerListView); auto* completerModel = new CompleterModel(); completer->setCompletionMode(QCompleter::CompletionMode::UnfilteredPopupCompletion); completer->setModelSorting(QCompleter::ModelSorting::UnsortedModel); lineEdit->setCompleter(completer); return lineEdit;
-
I'm not sure what you mean? The QLineEdit isn't the problem.
What I'm looking for is preventing the QCompleter from modifying the content of the QLineEdit when the user cursors through the items presented by the QCompleter. I want the text typed by the user to stay as it was typed while they are able to change the highlighted item in the QCompleter.
Ideally I'd like something equivalent to a Qt::NoneRole if I were to call setCompletionRole and instead manage the setting myself through a signal sent by the QCompleter when a choice is made by the user. Yes, I'm aware there is no Qt::NoneRole.
Edit: Basically it's best summed up as: I want to prevent the QCompleter from modifying the QLineEdit and want to do that myself.