当前位置:网站首页>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
边栏推荐
- JS cross reference
- O & M (21) make winpe startup USB flash disk
- Huawei interview question: tall and short people queue up
- WPF initialized event in The reason why binding is not triggered in CS
- 什么是外链和内链?
- HOOK Native API
- &nbsp; Difference from spaces
- The MariaDB database was found 12 hours late
- Compile a DLL without import table
- mysql 主从数据库同步失败的原因
猜你喜欢

约瑟夫环 数学解法

OP-diode-限制摆幅

Mathematical solution of Joseph Ring

Welfare lottery | what are the highlights of open source enterprise monitoring zabbix6.0

数据库的下一个变革方向——云原生数据库

MySQL extracts strings from table fields

编译一个无导入表的DLL

The broadcast module code runs normally in autojs4.1.1, but an error is reported in pro7.0 (not resolved)

An article to get you started VIM

Use of custom MVC
随机推荐
简单自定义MVC优化
Personal PC installation software
Simple custom MVC optimization
How can redis+aop customize annotations to achieve flow restriction
Golang BiliBili live broadcast bullet screen
Huawei interview question: tall and short people queue up
Mysql提取表字段中的字符串
Visual HTA form designer htamaker interface introduction and usage, Download | HTA VBS visual script writing
The MariaDB database was found 12 hours late
Formal and actual parameters, value passing and address passing
Servlet面试题
High paid programmers & interview questions series 63: talk about the differences between sleep (), yield (), join (), and wait ()
行政路线编码 字母+数字的排序方式
Servlet interview questions
Simulate activity startup mode in compose
Quick sort, cluster index, find the k-largest value in the data
shell统计某个字符串最后一次出现的位置之前的所有字符串
Tp6 framework integrates JWT for token authentication
Global and Chinese market for sensor screwdrivers 2022-2028: Research Report on technology, participants, trends, market size and share
2022 new test questions for safety management personnel of metal and nonmetal mines (small open pit quarries) and certificate examination for safety management personnel of metal and nonmetal mines (s