1. 去掉字符串多余的空格,回车等。

QString QString::simplified () const

Returns a string that has whitespace removed from the start and the end, and that has each sequence of internal whitespace replaced with a single space.

Whitespace means any character for which QChar::isSpace() returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.

Example:

     QString str = "  lots\t of\nwhitespace\r\n ";
str = str.simplified();
// str == "lots of whitespace";

2.QString 子串分隔

QString test("one,two,three,four,five");  
test=test.section(',',2,2); // "three"  
test=test.section(',',-2,-2); //"four"   
test=test.section(',',2); //"three,four,five"   

QString test("oneistwoisthree");  
test=test.section("is",1,1);//two

QT -- QString处理的更多相关文章

  1. Qt QString转char[]数组

    Qt QString转char[]数组 QString s1="1234456";char str[20]={0};strcpy(str,s1.toStdString().c_st ...

  2. QT QString 很全的使用 (转)

    QString, QByteArray, 和 QVariant这三个类和容器有许多相同之处,并且在一些情况下可以被当作特殊的容器. 同样,像容器,这些类使用隐式共享来优化内存和速度. 我们将从QStr ...

  3. QT QString类

    字符串有如下几个操作符 QString提供了一个二元的"+"操作符用于组合两个字符串,并提供了一个"+="操作符用于将一个字符串追加到另一个字符串的末尾,例如: ...

  4. Qt QString 和 LPCWSTR 的相互转换

    在windosw 编程中,常用到LPCWSTR 变量,QT中最常用到QString,下面提供QString和LPCWSTR 相互转换的方法 LPWSTR 转换成QString LPCWSTR str; ...

  5. Qt QString类及常用函数功能详解

    QString 是 Qt 编程中常用的类,除了用作数字量的输入输出之外,QString 还有很多其他功能,熟悉这些常见的功能,有助于灵活地实现字符串处理功能. QString 存储字符串釆用的是 Un ...

  6. qt QString 与 int,char的转换

    每次QString转换int或者char的时候都要查资料,记录一下,方便下次查看. 参考: http://blog.csdn.net/ei__nino/article/details/7297791 ...

  7. QT QString转char*,char*转QString;简单明了,看代码。

    //原始QStringQString qs = QString::fromLocal8Bit("我的");std::string strQs = qs.toStdString(); ...

  8. [Qt] QString 和 char* 转换

    (1) QString 转 char* char acResult[10240]; //QByteArray baResult = strResult.toLatin1(); QByteArray b ...

  9. Qt QString to char*

    QString转换成char * 的时候,一定要定义一个QBateArray的变量.不能连写 How can I convert a QString to char* and vice versa ? ...

  10. 【转】QT QString, wchar_t *, TCHAR, CString和其他字符或字符串类型的转化

    //QString to wchar_t *: const wchar_t * encodedName = reinterpret_cast<const wchar_t *>(fileNa ...

随机推荐

  1. TreeMap 的简单解释

    TreeMap的构造函数   可以传入 自定义的比较器.Map.SortedMap.   put方法: public V put(K key, V value) { Entry<K,V> ...

  2. 调用图灵API V2 遇到的坑

    1:遇到的第一个问题:跨域 解决办法: 第一种:使用query中的jsonp 可惜图灵要求post方法,而jsonp,只能使用get方法,才能跨域,失败 第二种:服务器添加header,可是我怎么去改 ...

  3. xrange和range的区别?

    range: 函数说明,range([start,] stop[, step]),根据start与stop指定的范围以及step设定的步长,生成一个列表. xrange:函数说明,xrange 用法与 ...

  4. BZOJ 5305: [Haoi2018]苹果树 组合计数

    一定要注意要乘阶乘,细节很多. code: #include <bits/stdc++.h> #define ll long long #define setIO(s) freopen(s ...

  5. Thread线程框架学习

    原文:https://www.cnblogs.com/wangkeqin/p/9351299.html Thread线程框架 线程定义:线程可以理解为一个特立独行的函数.其存在的意义,就是并行,避免了 ...

  6. CTF入门(一)

    ctf入门指南 如何入门?如何组队? capture the flag 夺旗比赛 类型: Web密码学pwn 程序的逻辑分析,漏洞利用windows.linux.小型机等misc 杂项,隐写,数据还原 ...

  7. SPA 首屏加载性能优化之 vue-cli3 拆包配置

    前言 现在已经是vue-cli3.x    webpack4.x 的时代了,但是网上很多拆包配置还是一些比较低版本的. 本文主要是分享自己的拆包踩坑经验. 主要是用了webpack4 的 splitC ...

  8. c++ 题解

    43题 #include <random> #include <iostream> int main() { ][] = { {,,,}, {,,,}, {,,,}}; ; n ...

  9. mysql 升序降序

    默认不指定,order by 按照升序排列. asc:升序 desc:降序

  10. 从0开始部署GPU集群-1:k8s部署生态

    1 k8s:nvidia deepops 2  批处理:华为volcano 3 工作流:argo