[Interest] Working with Q*Models and SQLite3 limitations
Jason H
scorp1us at yahoo.com
Wed Feb 26 17:14:48 CET 2014
I'm trying to work with SQLite 3 and QSqlQueryModel/QSqlTableModel. Normally I have not problem using these as data sets are small, and I'm interesting in the rows in returned order.
I recently tried to grab arbitrary data from the model sample model index would be (1000,0) - (1100,C) (first C columns of row 1000 to tor 11000) and ran into some snags.
int C = colMax != -1 ? colMax : colMax= columnCount();
int R = rowMax != -1 ? rowMax : rowMax= rowCount();
Pseducode runs after setQuery(sql):
for (int row = rowMin; row< rowMax; row++) {
for (int col = colMin; row< colMax; col++) {
Qstring d = model.data(row,col).toString();
}
}
However BOTH rowCount() and columnCount() return 0.
The only thing I can think of is to come up with a COUNT() query, but this requires me to write and maintain an additional query. The alternative, which I grimaced at, is to run through the query to get the count, then possibly iterate/reset backwards I have not yet even seen what happens when I request model.data(1000,0); Insight on how SQLite/Qt will behave for a not-yet-loaded row is appreciated.
I'm looking for more elegant solutions than what I can come up with, or a recommendation of approach.
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140226/d8d2d83f/attachment.html>
More information about the Interest
mailing list