当前位置:网站首页>QT foreach keyword
QT foreach keyword
2022-06-29 06:56:00 【Mr.codeee】
1. brief introduction
foreach Keyword is used to traverse Containers All items in .
foreach yes QtGlobal A macro defined in the header file , Usage is as follows :
Use foreach Your code is simpler than using iterators .
2. Examples of use
2.1 Traverse a QLinkedList<QString>
QLinkedList<QString> list;
...
QString str;
foreach (str, list)
qDebug() << str;
2.2 Out of the loop
And anything else c++ Same cycle structure , You can foreach Use curly braces around the loop body , You can use break Get out of the loop .
QLinkedList<QString> list;
...
foreach (const QString &str, list) {
if (str.isEmpty())
break;
qDebug() << str;
}2.3 Traverse QMap keys
QMap<QString, int> map;
...
foreach (const QString &str, map.keys())
qDebug() << str << ':' << map.value(str);
边栏推荐
- Hyperledger Fabric 2. X custom smart contract
- 力扣每日一题-第30天-1281.整数的各位积和之差
- How to change the password after forgetting the MySQL password (the latest version of 2022 detailed tutorial nanny level)
- RPC and RMI
- Linux Installation redis
- Are there too many programmers in China at present?
- Multithreading tool class completabilefuture
- Qt 容器类
- Qt QFileInfo简介
- Overlay histogram with density curve
猜你喜欢

消息队列之通过幂等设计和原子锁避免重复退款

Introduction to Ceres Quartet

Fault: ntfrs warning log for id13562

Linux Installation redis

Creating a new generation of production and service tools with robot education

Hyperledger Fabric 2. X custom smart contract

Fault: NetBt log for id4321

Testing grpc service with grpcui
![[when OSPF introduces direct connection routes, it makes a summary by using static black hole routes]](/img/a8/f77cc5e43e1885171e73f8ab543ee4.png)
[when OSPF introduces direct connection routes, it makes a summary by using static black hole routes]

. NETCORE uses redis to limit the number of interface accesses
随机推荐
把多个ROC曲线画在一张图上
QT (x): innosetup for software packaging
Part 63 - interpreter and compiler adaptation (II)
JDBC connects to the database and socket sends the client.
关于DDNS
How does schedulerx help users solve distributed task scheduling problems?
Presto-Trial
Vite快速上手
Unity AR Shadow 阴影
Idea use
Hyperledger Fabric 2. X custom smart contract
Li Kou daily question - day 30 -1281 Difference of sum of bit product of integer
RPC和RMI
软件工程师与软件开发区别? Software Engineer和Software Developer区别?
Daily question - force deduction - multiply the found value by 2
Qt 容器类
Ribbon service invocation and load balancing
转:侯宏:企业数字化转型的关键不是技术,而是战略
Service grid ASM year end summary: how do end users use the service grid?
开源二三事|ShardingSphere 与 Database Mesh 之间不得不说的那些事