Like many people these days I have been trying the different features that C++11 brings. One of my favorites is the \"range-based for loops\".
I understand that:
Chris Redford's answer also works for Qt containers (of course). Here is an adaption (notice I return a constBegin(), respectively constEnd() from the const_iterator methods):
class MyCustomClass{
QList data_;
public:
// ctors,dtor, methods here...
QList::iterator begin() { return data_.begin(); }
QList::iterator end() { return data_.end(); }
QList::const_iterator begin() const{ return data_.constBegin(); }
QList::const_iterator end() const{ return data_.constEnd(); }
};