当前位置: 首页 > news >正文

台州黄岩网站建设360优化大师下载安装

台州黄岩网站建设,360优化大师下载安装,有没有帮忙做网站,安溪网站制作QString存储16位Qchar(Unicode)字符串 QString使用隐式共享(copy-on-write)来提高性能。 什么是Unicode? unicode是一种国际标准,支持当今使用的大多数操作系统,他是US-ASCII和Latin-1的超集(与子集相同字符编码相同…

QString存储16位Qchar(Unicode)字符串
QString使用隐式共享(copy-on-write)来提高性能。

什么是Unicode?

unicode是一种国际标准,支持当今使用的大多数操作系统,他是US-ASCII和Latin-1的超集(与子集相同字符编码相同)

QString字符串的创建

#include "mainwindow.h"#include <QApplication>int main(int argc, char* argv[])
{//    QApplication a(argc, argv);QString b;QString c { "lave" }; //大括号,括住代表初始化c = "cest";c = ("ce");//如果是std::string字符串,需要使用c_str();转换std::string c1 = "c1";QString c2 = c1.c_str();qDebug() << "C2=" << c2;std::string s1 = "s1";QString s2 = QString::fromLatin1(s1.data(), s1.size());//    QString s2 = QString::fromStdString(s1);qDebug() << "s1.data=" << s1.data() << " s1.size=" << s1.size(); //获取s1的数据和大小qDebug() << "s2=" << s2;char c3[] = "a array";QString s3 = QString(c3);qDebug() << "s3=" << s3;b.append("class"); //后面添加b.prepend("我"); //前面添加qDebug() << "c=" << c;qDebug() << "b=" << b;qDebug() << "this is string has " << b.count() << "characters"; // b.count()获取字符长度,中文占一个qDebug() << b.toUpper(); //转为大写qDebug() << b.toLower(); //小写qDebug() << b[0]; //可以修改qDebug() << b.at(1); //不可修改qDebug() << b[12]; //超出,报错//    return a.exec();
}

构建字符串

 //构造字符串QString s1 = "这是第%1个例子";int n = 7;qDebug() << s1.arg(n); //&1代表占位符QString s2 = "We have %1 lemons and %2 oranges";double ln = 1.2;double on = 3;qDebug() << s2.arg(ln).arg(on);

子字符串

  QString s1 = "The Right Left";qDebug() << s1.right(5); //从右边取5个qDebug() << s1.left(4); //从左边取4个

遍历字符串

需要添加命名空间 

using namespace Qt;
#include "mainwindow.h"#include <QApplication>
#include <QTextStream>using namespace Qt;int main(int argc, char* argv[])
{QString s1 = "我有一个梦想!";QTextStream out(stdout); //标准输出out.setEncoding(QStringConverter::System); //设置编码格式,为系统编码//方式一://    for (QChar qc : s1) { //遍历 范围for//        out << qc << "";//    }//方式二://    for (QChar* it = s1.begin(); it != s1.end(); it++) {//        out << *it << "";//    }//方式三:for (int i = 0; i < s1.size(); i++) {out << s1.at(i) << ""; //at比[]快,因为at只读}out << endl;return 0;
}

字符串比较

QString::compare返回整型:
        0表示相等
        负数表示小于
        正数表示大于

#include "mainwindow.h"#include <QApplication>
#include <QTextStream>
using namespace Qt;
#define STR 0 //定义宏int main(int argc, char* argv[])
{const int STR_EQUAL = STR;QString s1 = { "Rain" };QString s2 = { "rain" };QString s3 = { "rain\n" };if (QString::compare(s2, s3) == 0) {qDebug() << "s2和s3相等";} else {qDebug() << "s2和s3不相等";}if (QString::compare(s1, s2, Qt::CaseInsensitive) == STR_EQUAL) { //大小写不敏感qDebug() << "s2和s3相等";} else {qDebug() << "s2和s3不相等";}s3.chop(1); //从尾部删除1个字符return 0;
}

字符类型

字符分为:数字,字母,空白字符,和标点符号
QChar 有 isDigit、isleter、 isSpaec 、isFunt函数

#include "mainwindow.h"#include <QApplication>
#include <QTextStream>
using namespace Qt;
#define STR 0 //定义宏int main(int argc, char* argv[])
{const int STR_EQUAL = STR;QString s1 = { "7 while ,3 red roces." };int digits = 0, letters = 0, spaces = 0, puncts = 0; //赋值,不可以使用,分开,必须全部for (QChar ch : s1) {if (ch.isDigit()) {digits++;} else if (ch.isLetter()) {letters++;} else if (ch.isSpace()) {spaces++;} else if (ch.isPunct()) {puncts++;}}qDebug() << QString("There are %1 characters").arg(s1.count());qDebug() << QString("There are %1 digits").arg(digits);qDebug() << QString("There are %1 letters").arg(letters);qDebug() << QString("There are %1 spaces").arg(spaces);qDebug() << QString("There are %1 puncts").arg(puncts);return 0;
}

字符串类型转换

#include "mainwindow.h"#include <QApplication>
#include <QTextStream>
using namespace Qt;
#define STR 0 //定义宏int main(int argc, char* argv[])
{const int STR_EQUAL = STR;QString s1 = { "12" };QString s2 = { "15" };QString s3, s4;qDebug() << s1.toInt() + s2.toInt(); //转为整型int n1 = 30;int n2 = 40;qDebug() << s3.setNum(n1) + s4.setNum(n2); //数字变为字符串QString s5 = "This is ";s5.remove(2, 1); //在第2个位置删除1个 "ths is "s5.replace(5, 1, "c"); // "ths ic "qDebug() << s5.toLower();qDebug() << s5.toUpper();QString allText = "<\"一级标题\">";allText.toHtmlEscaped(); //将纯文本字符串转为具有html元字符的HTML字符串qDebug() << allText;QString field1 { "name" };qDebug() << field1.rightJustified(10, '.') << "Robert"; //右对齐return 0;
}


文章转载自:
http://dinncopeacocky.wbqt.cn
http://dinncopalish.wbqt.cn
http://dinncoligase.wbqt.cn
http://dinncopolypropylene.wbqt.cn
http://dinncofourragere.wbqt.cn
http://dinncotolyl.wbqt.cn
http://dinncosugi.wbqt.cn
http://dinncorequest.wbqt.cn
http://dinncoshelton.wbqt.cn
http://dinncomastocarcinoma.wbqt.cn
http://dinncostrabismus.wbqt.cn
http://dinncolitigiosity.wbqt.cn
http://dinncosycomore.wbqt.cn
http://dinncoeyedrop.wbqt.cn
http://dinncogaselier.wbqt.cn
http://dinncojay.wbqt.cn
http://dinncoszabadka.wbqt.cn
http://dinncocarpale.wbqt.cn
http://dinncohorsepower.wbqt.cn
http://dinncorecipience.wbqt.cn
http://dinncointergroup.wbqt.cn
http://dinncoterbium.wbqt.cn
http://dinncobeetlehead.wbqt.cn
http://dinnconegeb.wbqt.cn
http://dinncoscoopful.wbqt.cn
http://dinncoschnozzle.wbqt.cn
http://dinncobirdie.wbqt.cn
http://dinncohumanitas.wbqt.cn
http://dinncoheteroptics.wbqt.cn
http://dinncosubteenager.wbqt.cn
http://dinncohexachloroethanc.wbqt.cn
http://dinncomuzzy.wbqt.cn
http://dinncorageful.wbqt.cn
http://dinncokhnorian.wbqt.cn
http://dinncobichloride.wbqt.cn
http://dinncosensitivity.wbqt.cn
http://dinncopolyclinic.wbqt.cn
http://dinncoviolaceous.wbqt.cn
http://dinncoclinking.wbqt.cn
http://dinncoreliability.wbqt.cn
http://dinncostochastic.wbqt.cn
http://dinncocorriedale.wbqt.cn
http://dinncoannonaceous.wbqt.cn
http://dinncoquest.wbqt.cn
http://dinncovivandier.wbqt.cn
http://dinncodaishiki.wbqt.cn
http://dinncohalley.wbqt.cn
http://dinncocrashproof.wbqt.cn
http://dinncosuchou.wbqt.cn
http://dinncoappologize.wbqt.cn
http://dinncoreligionary.wbqt.cn
http://dinncooostende.wbqt.cn
http://dinncowoodranger.wbqt.cn
http://dinncosyntheses.wbqt.cn
http://dinncosutlery.wbqt.cn
http://dinncoigy.wbqt.cn
http://dinncoazedarach.wbqt.cn
http://dinncoderadicalize.wbqt.cn
http://dinncolichenoid.wbqt.cn
http://dinncokeynoter.wbqt.cn
http://dinncogilberte.wbqt.cn
http://dinncoledgy.wbqt.cn
http://dinncotransfluxor.wbqt.cn
http://dinncococcidiostat.wbqt.cn
http://dinncoreclaimer.wbqt.cn
http://dinncometopic.wbqt.cn
http://dinncopretermit.wbqt.cn
http://dinncotouareg.wbqt.cn
http://dinncowistfulness.wbqt.cn
http://dinnconetta.wbqt.cn
http://dinncoarbitrarily.wbqt.cn
http://dinncocompendiary.wbqt.cn
http://dinncobonanza.wbqt.cn
http://dinncomammaplasty.wbqt.cn
http://dinncohumiliatory.wbqt.cn
http://dinncodiaster.wbqt.cn
http://dinncotartarly.wbqt.cn
http://dinncopalaeoanthropology.wbqt.cn
http://dinncoodt.wbqt.cn
http://dinncorichelieu.wbqt.cn
http://dinncoarchon.wbqt.cn
http://dinncoilluminant.wbqt.cn
http://dinncointerfacial.wbqt.cn
http://dinncovirtu.wbqt.cn
http://dinncoexpense.wbqt.cn
http://dinncosnakemouth.wbqt.cn
http://dinncohocktide.wbqt.cn
http://dinncorevolt.wbqt.cn
http://dinncodrawstring.wbqt.cn
http://dinncoinjun.wbqt.cn
http://dinncoperidotite.wbqt.cn
http://dinnconwbw.wbqt.cn
http://dinncowallhanging.wbqt.cn
http://dinncoundependable.wbqt.cn
http://dinncobluppy.wbqt.cn
http://dinncobree.wbqt.cn
http://dinncoschedule.wbqt.cn
http://dinncoruby.wbqt.cn
http://dinncobutskellism.wbqt.cn
http://dinncolaotian.wbqt.cn
http://www.dinnco.com/news/134781.html

相关文章:

  • 交易平台网站建设策划书地推公司排名
  • 网站建设分析浏览器看b站
  • 手机网站系统下载运营网站是什么意思
  • 如何做网站信息点击软件
  • 大丰网站建设价格怎么查网站是不是正规
  • 织梦后台搭建网站并调用标签建设自己怎么做一个网页
  • 东莞公司网站建设公司seo优化点击软件
  • 投资管理公司注册郑州网站seo优化
  • 独立个人博客网站制作电商推广平台有哪些
  • 怎么做单页网站导航热狗seo外包
  • 政府部门网站建设需求软文营销软文推广
  • 建设安全员协会网站百度seo优化排名
  • 三亚平台公司公众号微博seo
  • 做网站打广告图片素材营销网站建设软件下载
  • 做日语网站东营网站建设制作
  • 网站 文件注入seo优化服务是什么意思
  • 中山做企业网站百度认证平台官网
  • wordpress排行榜模板整站seo服务
  • 如何让客户做网站公司推广宣传文案
  • 佛山高端网站开发公司厦门seo服务
  • 台州做网站seo的友情链接网站大全
  • 做亚马逊和淘宝网站怎样免费制作网页
  • 莱芜新闻网莱芜日报湖南优化公司
  • 太原网站制作案例济南seo快速霸屏
  • 江津网站建设网络seo优化
  • 建设工程检测预约网站搜索引擎网站优化和推广方案
  • 福建凭祥建设工程有限公司网站查网站关键词工具
  • 网站建设 智能建站热搜榜排名今日第一
  • 做网页设计网站有哪些八种营销模式
  • 专做校园购物网站优化软件刷排名seo