16,225
社区成员
发帖
与我相关
我的任务
分享
struct StructInfo
{
QString key;
QString value1;
QString value2;
int arg1;
int arg2;
...;
}
#include <QList>
#include <QDebug>
#include <QString>
struct StructInfo {
QString key;
QString value1;
QString value2;
int arg1;
int arg2;
StructInfo() {
}
StructInfo(const QString &key, int arg1) {
this->key = key;
this->arg1 = arg1;
}
bool operator==(const StructInfo &other) const {
return this->key == other.key;
}
};
int main(int argc, char *argv[]) {
QList<StructInfo> list;
list.append(StructInfo("One", 1));
list.append(StructInfo("Tow", 2));
list.append(StructInfo("Three", 3));
for (StructInfo info : list) {
qDebug() << info.arg1;
}
qDebug() << "------------------------";
list.removeOne(StructInfo("One", 1));
for (StructInfo info : list) {
qDebug() << info.arg1;
}
return 0;
}