0

I am learning QT and using QSqlQuery to fetch data from database.

I have read this documentation. I know using next() function we can iterate through rows of QSqlQuery and using value(int col) function we can get data from current row.

But i dont know how to fetch row at particular index without using next() function.

Harikesh
  • 313
  • 3
  • 14

1 Answers1

1

I did not use QSqlQuery so far myself but from the documentation the seek method seems suitable to me:

bool QSqlQuery::seek ( int index, bool relative = false )

"Retrieves the record at position index, if available, and positions the query on the retrieved record. [...]"

Bowdzone
  • 3,827
  • 11
  • 39
  • 52
  • Yes i just found same solution myself. Actually i did not given too much attention to seek method because it returned bool. But when i went through doc again i found that seek method not only returns bool but also shifts cursor position at given index. Thanks anyway i will accept your answer. – Harikesh Oct 27 '14 at 09:49