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.

0

1 Answer 1

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. [...]"

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.