void FriendInfo::updateMemoName() { QString er; SqlDB *db = Sql::instance()->open(er); if (db) { QString sql = "SELECT * FROM "+ MatchData().objectName() + " WHERE uid = '" + data->getUid() + "'"; int rlt; QList<QObject *> objs = db->executeQuery(sql, MatchData().metaObject(), rlt, er); db->close(); if (objs.size() >= 1) { MatchData *md = qobject_cast<MatchData *>(objs.first()); if (md) { editLbl->setText(md->getEditname()); } } auto it = objs.begin(); while (it != objs.end()) { QObject *obj = *it; delete obj; obj = nullptr; ++it; } } }
void PersonItem::setUid(QString id) { ItemEditor::setUid(id); // load sql QString er; SqlDB *db = Sql::instance()->open(er); if (db) { QString sql = "SELECT * FROM "+ MatchData().objectName() + " WHERE uid = '" + uid + "'"; int rlt; QList<QObject *> objs = db->executeQuery(sql, MatchData().metaObject(), rlt, er); db->close(); if (objs.size() >= 1) { MatchData *md = qobject_cast<MatchData *>(objs.first()); if (md) { memoname = md->getEditname(); } } auto it = objs.begin(); while (it != objs.end()) { QObject *obj = *it; delete obj; obj = nullptr; ++it; } } }