Convert a Q_FOREACH to C++11 range-based for loop.
According to https://www.kdab.com/goodbye-q_foreach/ Q_FOREACH will be
deprecated.
I verified that this loop doesn't modify the container, and that the
container is const& so this won't cause a detach when calling begin().
I also tried converting this to a std::any_of call, but the result was
significantly less readable.