注: 大多数会给出优化建议, 不排除有错误的提示,自己分辨后优化修改。

静态分析代码工具
for 循环范围中(QString)[clazy range loop]的的范围中缺少引用

本质 QString imagePath 是个临时变量,每次for都要申请内存再销毁是没有必要的
//改后
void TextureLibrary::generateTexture(const QList<QString> &imagePathList)
{
if (!m_glTextureList.isEmpty()){
this->clearTexture();
}
for (auto &imagePath : imagePathList){
this->appendGlTexture(imagePath);
}
}
.ui 默认生成的槽就会报,不用管它
在类的构造和虚构中调用虚函数需要加类名

//改后
FlowLayout::~FlowLayout()
{
QLayoutItem *item;
while ((item = FlowLayout::takeAt(0)))
delete item;
}

《Effective C++》
条款02 对于单纯常量,最好以const对象或enum替换#define;对于形似函数的宏,最好改用inline函数替换#define
Qt 中建议 Q_GLOBAL_STATIC , 我个人喜欢写到类的静态成员变量中
class A{
public:
static QString _path;
};
QString A::_path = "xxx";
告警: QString(“%1, %2, %3”).arg(QString).arg(QString).arg(int);
消除: QString(“%1, %2, %3”).arg(QString,QString).arg(int);
告警: #include
消除: #include //可以看出很多标准库都不推荐直接include.h, 而是使用跳转文件Qt本身也是如此
告警: for(int i=0; i