我有以下课程
class LMJEntity : public QObject
{
Q_OBJECT
Q_PROPERTY(int Id READ getId WRITE setId)
};
class LMJDataMapper : public QObject
{
Q_OBJECT
virtual QList<LMJEntity *> *findAll(LMJPaging *paging){
QList<LMJEntity *> * result = NULL;
QSqlQuery query;
bool ret;
ret = query.exec(sql);
if(!ret){
errors = query.lastError().text();
}else
{
result = new QList<LMJEntity *>();
while(query.next()){
result->append(load(query));
}
}
return result;
}
};
这是正确的使用方法QList
吗?我应该使用QSharedPointer
而不是原始指针来避免内存泄漏吗?请给我一些建议。