changed Qt's foreach to C++11's for each