字面描述是循环会分离此列表。
避免出现此警告用如下方法;
1、定义新变量:
| 1 2 3 | const QStringList &list = oldList; for(auto &str : list){ } |
2、使用qt的宏:
| 1 2 3 4 5 6 | for(auto &str: qAsConst(list)){ } // c++11版本如下编译不通过,const一定要为变量值 for(auto &str: qAsConst(getList())){ } |
3、c++11 range-loop might detach Qt container (QStringList)避免方法-3YL的博客 (labisart.com)



