1:foreach 方式

1 // QList<outNode*> list;
2 foreach (outNode *i, list)
3 {
4     if (i->sn == tmpNode->sn)
5     {
6         qDebug() << "find in list!";
7     }
8 }

2:for 方式

 1 // QList<outNode*> list;
 2 for (int i = 0; i < list.size(); ++i)
 3 {
 4     outNode *node = (outNode *)list.at(i);
 5     if (node->sn == tmpNode->sn)
 6     {
 7         qDebug() << "find in database!";
 8         list.removeAt(i);       // 删除
 9         list.append(tmpNode);   // 添加
10         return;
11     }
12 }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-15
  • 2021-08-21
  • 2022-01-04
  • 2021-12-04
  • 2021-07-29
猜你喜欢
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
  • 2021-09-19
  • 2021-12-05
相关资源
相似解决方案