the example no reproduce the problem. i create a model for use whit the example and i dont see any problem.
please post a more complete example. if queryModel is a SQL model class. try to create a dummy DB to reproduce the problem
a dummy DB is a sqlite DB whit one table, whit the data to cause the problem.
// my model
int numItems = 300;
for (int row = 0; row < numItems ; ++row) {
queryModel->setItem(row, 0, item);
}
// not my code.
combo->setModel(queryModel);
combo->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
// MaxVisibleItems set
p->setMaxVisibleItems(20);
combo->setCompleter(p);
combo->show();
// my model
int numItems = 300;
QStandardItemModel * queryModel = new QStandardItemModel(numItems , 1);
for (int row = 0; row < numItems ; ++row) {
QStandardItem *item = new QStandardItem(QString("row %0").arg(row));
queryModel->setItem(row, 0, item);
}
// not my code.
QComboBox *combo = new QComboBox;
combo->setModel(queryModel);
combo->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
// MaxVisibleItems set
QCompleter *p = new QCompleter(queryModel);
p->setMaxVisibleItems(20);
combo->setCompleter(p);
combo->show();
To copy to clipboard, switch view to plain text mode
Bookmarks