43 completer()->setCompletionMode(QCompleter::PopupCompletion);
44 completer()->setCaseSensitivity(Qt::CaseInsensitive);
53 if (strings.size() == 1)
57 QString common_prefix;
63 if (char_index >= strings[0].size())
67 const QChar c = strings[0][char_index];
70 for (
int string_index = 1; string_index < strings.size(); string_index++)
72 const QString& str = strings[string_index];
73 if (char_index >= str.size() || str[char_index] != c)
86 if (
event->type() == QEvent::KeyPress)
88 QKeyEvent* k = (QKeyEvent*)
event;
89 if (k->key() == Qt::Key_Tab && k->modifiers() == Qt::NoModifier)
91 QCompleter* comp = completer();
93 QStringList completions;
94 for (
int i = 0; comp->setCurrentRow(i); i++)
96 completions.push_back(comp->currentCompletion());
99 if (max_common_prefix.size() >
currentText().size())
101 setEditText(max_common_prefix);
102 lineEdit()->setCursorPosition(max_common_prefix.size());
109 return ComboBox::event(
event);