Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
4.4.0
-
None
Description
QCompleterPrivate::showPopup(const QRect& rect) makes the assumption that no headers are shown.
It uses popup->sizeHintForRow(0) to calculate the height of the widget and allows for an additional scrollbar.
So if the view's headers are visible and only one completion if possible then the header and the scrollbar are visible but not the completion item.
Test case main.cpp to reproduce
#include <QtGui> #include <QtSql> int main( int argc, char* argv[] ) { QApplication app( argc, argv ); QTableView* view = new QTableView(); QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(":memory:"); db.open(); QSqlQuery query; query.exec( "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, " "number INTEGER, description VARCHAR(300))" ); query.exec( "INSERT INTO test VALUES(1, 10, 'First')" ); query.exec( "INSERT INTO test VALUES(2, 15, 'Second')" ); query.exec( "INSERT INTO test VALUES(3, 20, 'Third')" ); query.exec( "INSERT INTO test VALUES(4, 40, 'Forth')" ); QSqlTableModel *model = new QSqlTableModel(); model->setTable("test"); model->select(); view->setModel( model ); QLineEdit *lineEdit = new QLineEdit(); QCompleter *completer = new QCompleter(model); completer->setCompletionMode(QCompleter::PopupCompletion); completer->setPopup(view); lineEdit->setCompleter(completer); lineEdit->show(); app.exec(); }