I’ve been irritated for the way a QSqlQuery result-set is supposed to be processed for some time now - with while(query.next()) and getting the results via query.value(…). I was always thinking it would be nice if it were more accessible… namely, accessible using iterators.

To be able to do something like this:

for (auto &record: query) {
    // do something with
    record[0]
    // or
    record["ID"]
}

You have a simple .h file to include, and it will just work. [1]

{% gist 7346513 %}

The issue is that it is only tailored to match only this use-case - it can be improved to do more, and to allow more iterators over the same query, but I don’t really care to do that :)

[1] https://gist.github.com/ivan-cukic/7346513