Count rows in QSqlQueryModel?
-
wrote on 27 Aug 2012, 22:51 last edited by
Is there a way to count the amount of row a QSqlQueryModel holds without iterating through each record to see if it exist or would I be better off just making an additional QSqlQuery?
I thought rowCount() would work but it has simply confused me.
-
wrote on 28 Aug 2012, 06:05 last edited by
It depends.
If your database supports the QSqlDriver::QuerySize feature you can use rowCount() directly (otherwise it just returns the number of cached rows).
If not, having a dedicated COUNT query might be the most performant solution.
-
wrote on 28 Aug 2012, 10:29 last edited by
Hi!
I will give you an advice to search before posting - there were many posts here about it.
-
wrote on 1 Sept 2012, 19:13 last edited by
@Lukas Geyer Thank you. I'll have to look into this but sounds like something that could be preventing this from working the way I thought. I have never worked with MySql, so I will have to read more on it. For some reason I have a feeling I will like the iteration time with a query but I also have to consider poor network speeds also.
@tucnak Please don't respond to my post if they bother you. If you would like to please prove your point because I have looked. Provide a link to one of these many post. Should be easy as 1,2,3; right!
-
wrote on 3 Sept 2012, 04:52 last edited by
The MySQL driver should support QSqlDriver::QuerySize, so rowCount() should return the number of rows in the current query.
-
wrote on 3 Sept 2012, 17:54 last edited by
@Lukas Geyer Thank you very much for your response again, your wisdom is vast.
I still haven't come back to this but that is disconcerting because this means I am passing data wrong somewhere most likely if it isn't feeding me right. Will keep you updated when I come back to it I already have a idea what I need to do. Right now I am focusing on porting code to other OS's, fun...
5/6