Forum
Sign Up
× DataGrid for Qt.C++

DBGridTableView: howto fetch more rows?

11 years 7 months ago #1 by Mathias
hi,
I'm connection a DBGridTableView to a SQLITE database. The problem is, that it only displays the first 256 rows of the database table. How can I force the DBGridTableView to fetch more rows when the end of the view is reached (like the QTableView does).

thanks,
Mathias

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #2 by Piotr
Hi Mathias

SQLite database does not support reporting information about query sizes.

Create your own model class that inherits from QSqlTableModel and declare virtual bool select() function.

class MySQLiteSqlTableModel : public QSqlTableModel
{
Q_OBJECT

public:
MySQLiteSqlTableModel(QObject* parent = 0);

virtual bool select();
};

Create select() function as follows:
#include <QSqlDriver>
...
bool MySQLiteSqlTableModel::select()
{
bool result = QSqlTableModel::select();
if(result && !database().driver()->hasFeature(QSqlDriver::QuerySize))
while(canFetchMore())
fetchMore();

return result;
}

Regards,
Piotr

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #3 by Mathias
Hi Piotr,

thanks for your answer. From my point of view this is not an option, since using your workaround means that the whole database is loaded into memory, which is impossible with my 50GB database. ;)

How is it solved in the orginal QT tableview? Using this widget, the view automatically fetches more rows when the end of the table is reached by scrolling down (and I guess some records at the top of the table are thrown aways).

Kind regards,
Mathias

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #4 by Developer Machines
Support for fetch mode is not implemented at the moment by the following reason. In our opinion, the interface QSqlTableModel/QAbstractItemModel is not enough for the support of sequential mode for tables with large amounts of data. So QTableView use the RowCount() method after the fetchMore() has invoked. We think it is necessary to have Next, Prev, First, Next functions to support large tables (sequential mode). In this case the grid's scroller should have 3 pos only (First, Last, Current). According to my information QTablleVIew does not support this mode.

Please Log in or Create an account to join the conversation.

More
  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Moderators: Developer Machines
Time to create page: 0.144 seconds

Developer Newsletter

Join our Developer Machines newsletter to get informed on all the latest releases of the commercial components for Qt.C++, Delphi FireMonkey, updates and general knowledges.

Quick Support

Should you need any additional information about our products or licensing, please contact us at the following email addresses:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

Get in Touch

If you would like to purchase our products or services, but don’t know how to do it the right way, please feel free to contact us:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.( any questions related to our products or services )
  • This email address is being protected from spambots. You need JavaScript enabled to view it.( questions related to licensing )