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

Q3Datatable Qt3 support class never shows results that contain only one row

    XMLWordPrintable

Details

    Description

      The code line that does this is in Qt to q3datatable.cpp: Q3Datatable::loadNextPage() method's third last row:
      setNumRows( endIdx ? endIdx + 1 : 0 );

      This row is different in Qt 3.3.8 which works ok.

      #include <QtGui>
      #include <QtSql>
      #include <Q3DataTable>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
          db.setDatabaseName(":memory:");
          if (!db.open()) {
              QMessageBox::critical(0, qApp->tr("Cannot open database"),
                                    qApp->tr("Unable to establish a database connection.\n"
                                             "This example needs SQLite support. Please read "
                                             "the Qt SQL driver documentation for information how "
                                             "to build it.\n\n"
                                             "Click Cancel to exit."), QMessageBox::Cancel);
              return 1;
          }
      
          QSqlQuery query;
          query.exec("create table person (id int primary key, "
                     "firstname varchar(20), lastname varchar(20))");
          query.exec("insert into person values(101, 'Danny', 'Young')");
      //    query.exec("insert into person values(102, 'Christine', 'Holand')");
      //    query.exec("insert into person values(103, 'Lars', 'Gordon')");
      //    query.exec("insert into person values(104, 'Roberto', 'Robitaille')");
      //    query.exec("insert into person values(105, 'Maria', 'Papadopoulos')");
      
          query.exec("create table offices (id int primary key,"
                     "imagefile int,"
                     "location varchar(20),"
                     "country varchar(20),"
                     "description varchar(100))");
      
          Q3SqlCursor cursor("person", true, db);
          cursor.select();
          Q3DataTable dataTable(&cursor, true);
      
          dataTable.show();
          dataTable.refresh();
      
          return app.exec();
      }
      

      Attachments

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

        Activity

          People

            sorvig Morten Sørvig
            mpejcoch Martin Pejcoch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes