Given a QList<QAction*>
do you recommend writing a for loop as:
for(auto const& item: list)
Printable View
Given a QList<QAction*>
do you recommend writing a for loop as:
for(auto const& item: list)
You can do that.
If "list" is not const this will call non const versions of begin() and end(), causing the QList to detach if the reference count is greater than 1, i.e. create a "deep copy".
Cheers,
_
Thanks. How would you write it if the list is not const?
You either make it const
orCode:
const QList<QAction*> constList = list; for (.... : constList)
or you use Qt's foreachCode:
for (.... : const_cast<const QList<QAction*>& >(list))
Cheers,
_