当前位置:网站首页>QT qstringlist usage
QT qstringlist usage
2022-06-30 20:16:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
QStringList Class provides a list of strings from QList <QString> inherited , It provides fast index based access as well as fast insertion and removal Its member functions are used to manipulate this string list, such as append(),insert(), replace(), removeAll(), removeAt(), removeFirst(), removeLast(), and removeOne() etc. 1. Add string Can pass append(), Or use <<, Such as QStringList fonts; fonts << “Arial” << “Helvetica” << “Times” << “Courier”; // fonts:[ “Arial” ,”Helvetica”, “Times” , “Courier”] 2. Merge strings using join( ) QString str = fonts.join(“,”); // str == “Arial,Helvetica,Times,Courier” 3. Split string QString str = ” Arial,Helvetica, ,Times,Courier “; QStringList list1 = str.split(“,”); // list1: [ ” Arial “, ” Helvetica “,” “, ” Times “, ” Courier ” ] QStringList list2 = str.split(“,”, QString::SkipEmptyParts); // list2: [ ” Arial “, ” Helvetica “, ” Times “, ” Courier ” ] That is to say, if there is QString::SkipEmptyParts, Empty items will not appear in the result . By default , Blank items are reserved 4. Indexes IndexOf() The index() function returns the index of the first occurrence of a given string . and lastIndexOf() function , Returns the index of the last occurrence of a string . 5. Replace replaceInStrings() QStringList files; files << “$QTDIR/src/moc/moc.y” << “$QTDIR/src/moc/moc.l” << “$QTDIR/include/qconfig.h”; files.replaceInStrings(“$QTDIR”, “/usr/lib/qt”); // files: [ “/usr/lib/qt/src/moc/moc.y”, …] 6. Filter filter() Allows you to extract a new list containing only those strings containing a specific string ( Or match a specific regular expression ): QStringList list; list << “Bill Murray” << “John Doe” << “Bill Clinton”; QStringList result; result = list.filter(“Bill”); // result: [“Bill Murray”, “Bill Clinton”]
7. Traverse
QList<QString>::Iterator it = user.begin(),itend = user.end(); int i = 0; for (;it != itend; it++,i++){ if (*it == pFindLine->text()){// find , Highlight QModelIndex index = model->index(i); m_pTabList->setCurrentIndex(index); break; } }
Publisher : Full stack programmer stack length , Reprint Please indicate the source :https://javaforall.cn/132117.html Link to the original text :https://javaforall.cn
边栏推荐
- Taiwan SSS Xinchuang sss1700 replaces cmedia cm6533 24bit 96KHz USB audio codec chip
- Playwright - 滚动条操作
- Client请求外部接口标准处理方式
- Audio and video architecture construction in the super video era | science and Intel jointly launched the second season of "architect growth plan"
- 为什么一定要从DevOps走向BizDevOps?
- Torchdrug -- drug attribute prediction
- 将秒数转换为**小时**分钟
- 杰理之检测灵敏度级别确定【篇】
- Jerry's touch key recognition process [chapter]
- 杰理之触摸按键识别流程【篇】
猜你喜欢

建立自己的网站(20)
Django上传excel表格并将数据写入数据库的详细步骤

25:第三章:开发通行证服务:8:【注册/登录】接口:接收并校验“手机号和验证码”参数;(重点需要知道【利用redis来暂存数据,获取数据的】的应用场景)(使用到了【@Valid注解】参数校验)

qt中toLocal8Bit和toUtf8()有什么区别

Introduction to neural network (Part 1)

8 - 函数

DEX文件解析 - method_ids解析

What is the difference between tolocal8bit and toutf8() in QT

Tencent conference application market was officially launched, with more than 20 applications in the first batch

Build your own website (20)
随机推荐
杰理之触摸按键识别流程【篇】
Why must a digital transformation strategy include continuous testing?
如何做好测试用例设计
Source code analysis of redis ziplist compressed list
TorchDrug--药物属性预测
Jerry's touch key recognition process [chapter]
操作系统面试题汇总(不定期更新)
杰理之触摸按键识别流程【篇】
The former king of fruit juice sold for 1.6 billion yuan
Smarter! Airiot accelerates the upgrading of energy conservation and emission reduction in the coal industry
杰理之检测灵敏度级别确定【篇】
CADD课程学习(2)-- 靶点晶体结构信息
25:第三章:开发通行证服务:8:【注册/登录】接口:接收并校验“手机号和验证码”参数;(重点需要知道【利用redis来暂存数据,获取数据的】的应用场景)(使用到了【@Valid注解】参数校验)
Primary school, session 3 - afternoon: Web_ sessionlfi
Tensorflow2.4 implementation of repvgg
Tensorflow2.4实现RepVGG
Originpro 2021 with installation tutorial
Jerry's touch key recognition process [chapter]
Why should offline stores do new retail?
Torchdrug -- drug attribute prediction