Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-2274

A QCompleter with a popup does not display the items in the view properly if the view's headers are visible.

    XMLWordPrintable

Details

    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(); 
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            bdo Jo Asplin (Inactive)
            admin Administrator
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes