当前位置:网站首页>Utilisation de foreach en Qt
Utilisation de foreach en Qt
2022-06-30 03:13:00 【Mon... Angle2016】
Exemple:
En standardC++Moyenne,Non.foreachMots clés,Mais dansQTMoyenne,Vous pouvez utiliser ce mot - clé,La raison principale est queQTJ'ai ajouté ce mot - clé,C'est comme...slotsEtsignals、emitAttends..AugmentationforeachLes mots clés sont pré - traités au moment de la compilation.
Utilisation:
foreach (varItem , Items) // foreach(variable ,container)Parmi eux,varItem(variable)C'est un conteneurItems(container)Un des éléments,équivalent à:variable=container.item .La traversée passe du début à la fin.
Comme le code suivant
QStringList slt = {"abc", "qwe", "upo"};
foreach(QString s , slt )
{
cout<<s<<endl;
}
// Le résultat est:
abc
qwe
upo QStringList test;
test.append("aaaa");
test.append("bbbb");
test.append("cccc");
QString tempa;
QString tempb;
int i = 0;
foreach(tempa, test)
{
qDebug() << tempa << endl;
if(1==i)
tempb = tempa;
i++;
}
qDebug() << tempb << endl;Résultats des opérations:

Code du paragraphe précédent, C'est clair. ,foreachRôle de la fonction,BientôttestLes éléments à l'intérieur, Transmis par boucle à tempa
边栏推荐
- ZABBIX trigger explanation
- JS 字母和数字的相互转换
- 外汇交易平台哪个好?有监管的资金就安全吗?
- 如何实现远程协同办公,收好这份攻略!
- The broadcast module code runs normally in autojs4.1.1, but an error is reported in pro7.0 (not resolved)
- 发现mariadb数据库时间晚了12个小时
- Welfare lottery | what are the highlights of open source enterprise monitoring zabbix6.0
- How to use redis to realize the like function
- Cross domain, CORS, jsonp
- F1C100S自制开发板调试过程
猜你喜欢

Redis高并发分布式锁(学习总结)

广播模块代码在autojs4.1.1版本运行正常,但在pro7.0版本上运行报错(未解决)
![[practical skills] how to write agile development documents](/img/38/4bab396891ce3cc42595ae8cfd45ce.png)
[practical skills] how to write agile development documents

HOOK Native API

MySQL extracts strings from table fields

golang bilibili直播弹幕姬

图的邻接矩阵存储 C语言实现BFS

High paid programmers & interview questions series 63: talk about the differences between sleep (), yield (), join (), and wait ()

Principle, advantages and disadvantages of three operating modes of dc/dc converter under light load

mysql 主从数据库同步失败的原因
随机推荐
IDEA 远程调试 Remote JVM Debug
[wechat applet] how did the conditional rendering list render work?
2. 成功解决 BUG:Exception when publishing, ...[Failed to connect and initialize SSH connection...
2022 tool fitter (Advanced) and tool fitter (Advanced) certificate examination
Jvxetable sub table record loading completion event
发现mariadb数据库时间晚了12个小时
DC/DC变换器轻载时三种工作模式的原理及优缺点
Quick sort, cluster index, find the k-largest value in the data
Differences between comparable and comparator
Sorting method of administrative route code letter + number
X书6.89版本shield-unidbg调用方式
&nbsp;与空格的区别
Hands on in-depth learning notes (XV) 4.1 Multilayer perceptron
MySQL extracts strings from table fields
Visual HTA form designer htamaker interface introduction and usage, Download | HTA VBS visual script writing
Reasons for MySQL master-slave database synchronization failure
Global and Chinese markets for active transdermal drug delivery devices 2022-2028: Research Report on technology, participants, trends, market size and share
How can redis+aop customize annotations to achieve flow restriction
Distributed file system fastdfs
[practical skills] how to write agile development documents