https://www.kdab.com/goodbye-q_foreach/
Conclusion
Here’s why you’ll want to port away from Q_FOREACH, ideally to C++11 ranged for-loops:
Q_FOREACH is deprectaed since 5.7
It only works efficiently on (some) Qt containers; it performs prohibitively expensive on all std containers, QVarLengthArray, and doesn’t work at all for C arrays.
Even where it works as advertised, it typically costs ~100 bytes of text size more per loop than the C++11 ranged for-loop.
Its unconditionally taking a copy of the container makes it hard to reason about the loop.