当前位置:网站首页>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
边栏推荐
- Mathematical solution of Joseph Ring
- OP-diode-限制摆幅
- Cross domain, CORS, jsonp
- Which is a good foreign exchange trading platform? Is it safe to have regulated funds?
- Welfare lottery | what are the highlights of open source enterprise monitoring zabbix6.0
- 怎样的外汇交易平台是有监管的,是安全的?
- Visual HTA form designer htamaker interface introduction and usage, Download | HTA VBS visual script writing
- General paging (2)
- &nbsp; Difference from spaces
- IDEA 远程调试 Remote JVM Debug
猜你喜欢
随机推荐
Global and Chinese market of ULTRACENTRIFUGES 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market for sensor screwdrivers 2022-2028: Research Report on technology, participants, trends, market size and share
外汇交易平台哪个好?有监管的资金就安全吗?
Redis高并发分布式锁(学习总结)
How to realize remote collaborative office, keep this strategy!
Visual HTA form designer htamaker interface introduction and usage, Download | HTA VBS visual script writing
Study diary: February 15, 2022
Shell counts all strings before the last occurrence of a string
图的邻接矩阵存储 C语言实现BFS
O & M (21) make winpe startup USB flash disk
数据库的下一个变革方向——云原生数据库
What kind of foreign exchange trading platform is regulated and safe?
简单自定义mvc
自定义JvxeTable的按钮及备注下$set的用法
*Write a program to initialize a string object with a vector < char> container*/
GTK interface programming (I): Environment Construction
2. successfully solved bug:exception when publishing [Failed to connect and initialize SSH connection...
[live broadcast notes 0629] Concurrent Programming II: lock
Possible problems in MySQL cross database operation with database name
2022 tool fitter (Advanced) and tool fitter (Advanced) certificate examination