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. Laravel —— could not find driver

    Laravel 中的数据库是以 PDO 的方式连接的 数据库连接失败时,先检查问题所在,再对症下药 本文以 pgsql 为例 1.判断 pgsql 是否启动 $ ps -ef | grep pgsql ...

  2. LeetCode 1087. Brace Expansion

    原题链接在这里:https://leetcode.com/problems/brace-expansion/ 题目: A string S represents a list of words. Ea ...

  3. 【BZOJ4237】 稻草人 CDQ分治+单调栈

    ## 题目描述 JOI村有一片荒地,上面竖着N个稻草人,村民们每年多次在稻草人们的周围举行祭典. 有一次,JOI村的村长听到了稻草人们的启示,计划在荒地中开垦一片田地.和启示中的一样,田地需要满足以下 ...

  4. sql server 能按照自己规定的字段顺序展示

    工作中遇到,需要把sql 查询的按照指定的顺序显示 select plantname,cc_type,all_qty from VIEW_TEMP_DAY_CVT_CAP a where a.docd ...

  5. vue-cli之路由独立成JS文件之后,如何在路由中获取vuex属性或者设置国际化i18n的当前使用语言

    国际化vue-i18n的使用: import Vue from 'vue'; import VueI18n from 'vue-i18n'; // 引入语言包 import zh from '@/co ...

  6. C博客作业01——分支,顺序结构

    C博客作业01--分支,顺序结构 0.展示PTA总分 1本章学习内容 1.1学习内容总结 1)格式化输出函数printf(),scanf(). 它是什么? 对于初学者而言,一开始了解接触它们,只是被硬 ...

  7. shell脚本编程基础之for循环

    循环结构 循环需要有进入条件和退出条件,如果没有退出条件,则就会一直循环下去 for 变量 in 列表:do 循环体 done 生成列表及示例 {1..100}:生成1到100的整数列表 `comma ...

  8. Android中LayoutInflater()方法

    在实际开发中LayoutInflater这个类还是非常有用的,它的作用类似于findViewById().不同点是LayoutInflater是用来找res/layout/下的xml布局文件,并且实例 ...

  9. mysql 提示ssl问题

    问题信息如下: rements SSL connection must be established by default if explicit option isn't set. For comp ...

  10. Spring AOP的实现记录操作日志

    适用场景: 记录接口方法的执行情况,记录相关状态到日志中. 注解类:LogTag.java package com.lichmama.spring.annotation; import java.la ...