You can use a QSortFilterProxyModel Something like:
for (int x = 0; x < 1000; x++)
{
model->insertRow(model->rowCount());
model
->setData
(model
->index
(model
->rowCount
() - 1,
0),
QString("hello%1").
arg(x
), Qt
::DisplayRole);
}
proxy->setSourceModel(model);
cb->setModel(proxy);
cb->setEditable(true);
cb->setCompleter(0);
// When the edit text changes, use it to filter the proxy model.
connect(cb,
SIGNAL(editTextChanged
(QString)), proxy,
SLOT(setFilterWildcard
(QString)));
QStringListModel * model = new QStringListModel;
for (int x = 0; x < 1000; x++)
{
model->insertRow(model->rowCount());
model->setData(model->index(model->rowCount() - 1, 0), QString("hello%1").arg(x), Qt::DisplayRole);
}
QComboBox * cb = new QComboBox;
QSortFilterProxyModel * proxy = new QSortFilterProxyModel;
proxy->setSourceModel(model);
cb->setModel(proxy);
cb->setEditable(true);
cb->setCompleter(0);
// When the edit text changes, use it to filter the proxy model.
connect(cb, SIGNAL(editTextChanged(QString)), proxy, SLOT(setFilterWildcard(QString)));
To copy to clipboard, switch view to plain text mode
Bookmarks