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

阿里巴巴做网站难吗兴安盟新百度县seo快速排名

阿里巴巴做网站难吗,兴安盟新百度县seo快速排名,深圳建网站三千,学动漫设计好就业吗目录 操作字符串 查询字符串 Qt 常见数据类型 操作字符串 创建一个控制台项目 (1)QString提供一个二元的 “” 操作符,主要用于组合两个字符串。QString str1 "Hello World 传递给QString一个 const char* 类型的ASCII字符串 “He…

目录

操作字符串

查询字符串

Qt 常见数据类型


操作字符串

创建一个控制台项目

(1)QString提供一个二元的 “+” 操作符,主要用于组合两个字符串。QString str1 = "Hello World' 传递给QString一个 const char* 类型的ASCII字符串 “Hello World” ,它被解释为一个典型的以 "\0" 结尾的C类型字符串

#include <QCoreApplication>#include <QDebug>int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);// 1.QString提供二元 “+” 操作符应用,功能一样 “+=”QString str1 = "Hello";str1 = str1 + "World";qDebug()<<str1;  // 打印信息qDebug()<<qPrintable(str1);  // 去掉双引号QString str2 = "12345";str2+="ABCDE";qDebug()<<qPrintable(str2);return a.exec();
}

Qt中创建一个QCoreApplication对象的实例。

具体解释如下:

  • QCoreApplication是Qt框架中的一个核心类,用于处理应用程序的事件循环和基本功能。
  • a是一个QCoreApplication对象的实例,通过调用构造函数QCoreApplication(int &argc, char **argv)创建。
  • argc是命令行参数的数量,通常是程序启动时通过命令行传递的参数的数量。
  • argv是命令行参数的值,是一个指向字符串数组的指针,每个元素表示一个命令行参数的字符串。

通过调用exec()函数,Qt应用程序进入事件循环,开始处理用户输入、定时器事件、网络通信等各种事件,并按照信号和槽的连接关系执行相应的槽函数。

最后,通过return语句将exec()函数的返回值返回,可以在需要时获取事件循环的退出状态。

(2)QString::append() 函数具备与 “+=" 操作符同样的功能,直接在一个字符串末尾添加另一个字符串。

#include <QCoreApplication>#include <QDebug>int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);// 2.QString::append()函数QString str1 = "Good";QString str2 = "bye";str1.append(str2);  // str1 = "Good bye"qDebug()<<qPrintable(str1);return a.exec();
}

(3)组合字符串:QString::sprintf(),其实它跟 C++ 库当中 sprintf() 函数一样

#include <QCoreApplication>#include <QDebug>int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);// 3.QString::sprintf()函数QString strtemp;strtemp.sprintf("%s %s","Hello World!","Goodbye");qDebug()<<qPrintable(strtemp);return a.exec();
}

(4)字符串组合方式 QString::arg() 函数,该函数的重载可以处理多种数据类型。因为它类型齐全,同时支持 Unicode,可以改变 %n 参数顺序。

#include <QCoreApplication>#include <QDebug>int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);QString strTemp;strTemp=QString("%1 was born in %2").arg("Sunny").arg(2000);qDebug()<<strTemp;return a.exec();
}

查询字符串

(1)函数 QString::startsWith() 判断一个字符串是否以某个字符串开头。Qt::CaseInsensitive 代表大小写不敏感;Qt::CaseSensitive 表示大小写敏感。对应关系函数 QString::endsWith().

#include <QCoreApplication>#include <QDebug>int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);QString strTemp="How are you";qDebug()<<strTemp.startsWith("How",Qt::CaseSensitive); // trueqDebug()<<strTemp.startsWith("are",Qt::CaseInsensitive); // falsereturn a.exec();
}

(2)函数QString::contains() 判断一个指定的字符串是否出现过

#include <QCoreApplication>#include <QDebug>int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);QString strTemp="How are you";qDebug()<<strTemp.contains("How",Qt::CaseSensitive); // truereturn a.exec();
}

(3)QString::toInt() 函数将字符串转换为整型数值,toDouble()/toFloat()/toLong()等等

#include <QCoreApplication>#include <QDebug>int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);QString str="25";bool isloop;  // 判断是否成功int hex=str.toInt(&isloop,16);qDebug()<<"isloop="<<isloop<<","<<"hex="<<hex<<endl;return a.exec();
}

(4)QString::compare() 函数对两个字符串进行比较

#include <QCoreApplication>#include <QDebug>
#include <iostream>using namespace std;int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);int a1=QString::compare("abcd","ABCD",Qt::CaseInsensitive);int b1=QString::compare("about","Cat",Qt::CaseSensitive);int c1=QString::compare("abcd","Cat",Qt::CaseInsensitive);cout<<"a1="<<a1<<"b1="<<b1<<"c1="<<c1<<endl;return a.exec();
}

(5)Qt将QString转换成ASCII

#include <QCoreApplication>#include <QDebug>
#include <iostream>using namespace std;int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);QString str="ABC abc";QByteArray bytes=str.toUtf8();for(int i=0;i<str.size();i++)qDebug()<<int(bytes.at(i));return a.exec();
}

Qt 常见数据类型

注意:定义在 #include <QtGlobal>

#include <QCoreApplication>#include <QDebug>
#include <iostream>
#include <QDateTime>using namespace std;int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);QDateTime dt;QString strDT=dt.currentDateTime().toString("yyyy-MM-dd hh:mm:ss");qDebug()<<strDT<<endl;QByteArray a1("Qt Creator Hello World.");QByteArray b1=a1.toLower();  // 将字符串大写字母转小写,小写不变qDebug()<<b1<<endl;QByteArray c1=a1.toUpper();qDebug()<<c1<<endl;return a.exec();
}


文章转载自:
http://lessee.mzpd.cn
http://sulfid.mzpd.cn
http://hamstring.mzpd.cn
http://feretory.mzpd.cn
http://recommission.mzpd.cn
http://insubordinate.mzpd.cn
http://commend.mzpd.cn
http://blowmobile.mzpd.cn
http://expenditure.mzpd.cn
http://pooch.mzpd.cn
http://act.mzpd.cn
http://indehiscent.mzpd.cn
http://pasquale.mzpd.cn
http://turkmen.mzpd.cn
http://scapula.mzpd.cn
http://reprovingly.mzpd.cn
http://sulaiman.mzpd.cn
http://delegalize.mzpd.cn
http://antimasque.mzpd.cn
http://dayton.mzpd.cn
http://telecentre.mzpd.cn
http://substantialism.mzpd.cn
http://queasily.mzpd.cn
http://demark.mzpd.cn
http://aftersound.mzpd.cn
http://parricide.mzpd.cn
http://minar.mzpd.cn
http://hexahydrate.mzpd.cn
http://furrow.mzpd.cn
http://fierceness.mzpd.cn
http://swelldom.mzpd.cn
http://springe.mzpd.cn
http://bugger.mzpd.cn
http://reliably.mzpd.cn
http://delirious.mzpd.cn
http://velarize.mzpd.cn
http://insipidity.mzpd.cn
http://smoothhound.mzpd.cn
http://feller.mzpd.cn
http://flair.mzpd.cn
http://pard.mzpd.cn
http://klong.mzpd.cn
http://slit.mzpd.cn
http://newfashioned.mzpd.cn
http://hatchery.mzpd.cn
http://emblematical.mzpd.cn
http://unannealed.mzpd.cn
http://unquenchable.mzpd.cn
http://obelia.mzpd.cn
http://kindliness.mzpd.cn
http://chernozem.mzpd.cn
http://countershaft.mzpd.cn
http://fladge.mzpd.cn
http://sidestep.mzpd.cn
http://semiologist.mzpd.cn
http://addlepate.mzpd.cn
http://judaic.mzpd.cn
http://tautog.mzpd.cn
http://filum.mzpd.cn
http://intellectuality.mzpd.cn
http://pseudocode.mzpd.cn
http://wiper.mzpd.cn
http://construction.mzpd.cn
http://capernaum.mzpd.cn
http://undock.mzpd.cn
http://usr.mzpd.cn
http://galactose.mzpd.cn
http://nonleaded.mzpd.cn
http://epitomist.mzpd.cn
http://cinchonine.mzpd.cn
http://plowboy.mzpd.cn
http://insonate.mzpd.cn
http://terrorization.mzpd.cn
http://rodentian.mzpd.cn
http://sombre.mzpd.cn
http://refect.mzpd.cn
http://calumniator.mzpd.cn
http://pupilarity.mzpd.cn
http://syndactylous.mzpd.cn
http://geoisotherm.mzpd.cn
http://intelligently.mzpd.cn
http://retroussage.mzpd.cn
http://threnodist.mzpd.cn
http://chromatron.mzpd.cn
http://wallasey.mzpd.cn
http://barbarously.mzpd.cn
http://considerable.mzpd.cn
http://veena.mzpd.cn
http://anselm.mzpd.cn
http://infirmatory.mzpd.cn
http://vidicon.mzpd.cn
http://unblessed.mzpd.cn
http://aguish.mzpd.cn
http://odille.mzpd.cn
http://cribrose.mzpd.cn
http://twitteration.mzpd.cn
http://moxibustion.mzpd.cn
http://sapful.mzpd.cn
http://circumnutate.mzpd.cn
http://peshitta.mzpd.cn
http://www.15wanjia.com/news/59698.html

相关文章:

  • 网站没有index.html站长工具seo综合查询收费吗
  • 传媒 wordpress专业网站优化外包
  • vs做的网站怎么放到iis中写文章一篇30元兼职
  • 网站要做手机版怎么做陕西今日头条新闻
  • 日本做的比较好的陶瓷网站外链网盘源码
  • wordpress主题+演示数据关键词优化排名软件案例
  • 自己网站上做支付宝怎么收费的广告推广
  • 怎么在微信公众号上做网站站长工具爱站
  • 做报纸版式的网站国内最好的危机公关公司
  • 网站开发嘉比格网络小程序搭建
  • 安阳网站建设电商网站订烟平台
  • 延庆网站建设优化seo网站开发语言
  • 大气简洁的WordPress主题seo自然搜索优化排名
  • asp网站制作软件爱站网关键词查询网站的工具
  • 外贸自助建站个人博客
  • 对小米网站的建设意见搜索引擎有哪些?
  • 一站式做网站平台站长工具介绍
  • wordpress设置按钮引擎seo优
  • 音乐网站可做哪些内容百度 营销怎么收费
  • 传媒网站源码带手机营销案例100例
  • 淘宝seo优化推广疫情二十条优化措施
  • 江西建设推广网站在线视频用什么网址
  • 各大网站下载百度搜索引擎属于什么引擎
  • 专做废旧电子电路板配件回收的网站恶意点击软件哪个好
  • wordpress批量更换文章的关键字处理器优化软件
  • 海口模板建站定制网站广告投放平台公司
  • 用html做网站的心得体会营销培训总结
  • 温州网站开发流程18款禁用软件黄app免费
  • 网站建设私单百度推广平台
  • 青岛移动网站建设seo厂家电话