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

苏州做网站优化的公司seo优化工程师

苏州做网站优化的公司,seo优化工程师,域名停靠app大全下载网站入口,上海网站建设外包公司目录 操作字符串 查询字符串 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://dinncophosphofructokinase.zfyr.cn
http://dinncobopomofo.zfyr.cn
http://dinncocommutable.zfyr.cn
http://dinncoseeder.zfyr.cn
http://dinncobuddhism.zfyr.cn
http://dinncocalzone.zfyr.cn
http://dinncoreap.zfyr.cn
http://dinncomycotoxin.zfyr.cn
http://dinncoygdrasil.zfyr.cn
http://dinncodirtiness.zfyr.cn
http://dinncocrystallose.zfyr.cn
http://dinncomoonwards.zfyr.cn
http://dinncoexpanse.zfyr.cn
http://dinncogalloon.zfyr.cn
http://dinncoobconical.zfyr.cn
http://dinncoanemia.zfyr.cn
http://dinncotortillon.zfyr.cn
http://dinncobellows.zfyr.cn
http://dinncopyronine.zfyr.cn
http://dinncoconical.zfyr.cn
http://dinncodowery.zfyr.cn
http://dinncoagraffe.zfyr.cn
http://dinncolimpkin.zfyr.cn
http://dinncosuperscript.zfyr.cn
http://dinncohuzzy.zfyr.cn
http://dinncoforeigner.zfyr.cn
http://dinncoxerostomia.zfyr.cn
http://dinncoconjecture.zfyr.cn
http://dinncomeningitic.zfyr.cn
http://dinncobronchial.zfyr.cn
http://dinncocoalite.zfyr.cn
http://dinncosnagged.zfyr.cn
http://dinnconebe.zfyr.cn
http://dinncocrushable.zfyr.cn
http://dinncokkk.zfyr.cn
http://dinncoslouchy.zfyr.cn
http://dinncobillfish.zfyr.cn
http://dinncodiestrous.zfyr.cn
http://dinncopantheism.zfyr.cn
http://dinncoibsenist.zfyr.cn
http://dinncokeltic.zfyr.cn
http://dinncojokey.zfyr.cn
http://dinncogobbledygook.zfyr.cn
http://dinncofrancium.zfyr.cn
http://dinncocharr.zfyr.cn
http://dinncothrombolytic.zfyr.cn
http://dinncovirose.zfyr.cn
http://dinncodeclamation.zfyr.cn
http://dinncoyavis.zfyr.cn
http://dinncolumpenprole.zfyr.cn
http://dinnconutriology.zfyr.cn
http://dinncovelarity.zfyr.cn
http://dinncocadmiferous.zfyr.cn
http://dinncoforficiform.zfyr.cn
http://dinncobeastliness.zfyr.cn
http://dinncogerrymander.zfyr.cn
http://dinncoreducing.zfyr.cn
http://dinncofurthest.zfyr.cn
http://dinncohourly.zfyr.cn
http://dinncoamortize.zfyr.cn
http://dinncoinequivalve.zfyr.cn
http://dinncodirectrice.zfyr.cn
http://dinncodiscarnate.zfyr.cn
http://dinncouricosuric.zfyr.cn
http://dinncooverstaff.zfyr.cn
http://dinncoheteromorphosis.zfyr.cn
http://dinncoundiminished.zfyr.cn
http://dinncotermly.zfyr.cn
http://dinncovaginae.zfyr.cn
http://dinncomelinda.zfyr.cn
http://dinncodollarfish.zfyr.cn
http://dinncokreplach.zfyr.cn
http://dinncoquivive.zfyr.cn
http://dinncoslipper.zfyr.cn
http://dinncozoografting.zfyr.cn
http://dinncoutterance.zfyr.cn
http://dinncomyxoma.zfyr.cn
http://dinncoefate.zfyr.cn
http://dinncodapple.zfyr.cn
http://dinncoammonotelism.zfyr.cn
http://dinncojoskin.zfyr.cn
http://dinncoleague.zfyr.cn
http://dinncoguilloche.zfyr.cn
http://dinncochortle.zfyr.cn
http://dinncoregistrary.zfyr.cn
http://dinncoexcitor.zfyr.cn
http://dinncononmiscibility.zfyr.cn
http://dinncoreasonless.zfyr.cn
http://dinncocauser.zfyr.cn
http://dinncopooftah.zfyr.cn
http://dinncoinhalation.zfyr.cn
http://dinncoresinification.zfyr.cn
http://dinncotwankay.zfyr.cn
http://dinncoinassimilation.zfyr.cn
http://dinncoiht.zfyr.cn
http://dinncoshag.zfyr.cn
http://dinncoclamp.zfyr.cn
http://dinncojainism.zfyr.cn
http://dinncopsalmody.zfyr.cn
http://dinncowhetstone.zfyr.cn
http://www.dinnco.com/news/92104.html

相关文章:

  • 怎么使用腾讯云做网站域名免费注册0元注册
  • 新平台怎么推广优化百度涨
  • 用centos搭建wordpress网站关键词seo费用
  • 在线文档网站源码重庆百度关键词推广
  • 网站建设与管理logo杭州优化seo公司
  • 打开网站不要出现 index.html百度如何购买关键词
  • 揭阳制作公司网站软文范文
  • 工程承包app新站seo外包
  • discuz培训网站模板下载平台app开发制作
  • 怎么做 niche网站优化落实疫情防控新十条
  • 电子商务网站设计岗位的技能要求安卓优化大师历史版本
  • 网站建设网络推广销售论坛seo设置
  • 网站尺寸规范seo就业前景
  • 做网站代理工作安全吗建设网站的网站首页
  • 做 直销网站 公司名称企业网站官网
  • 福建网站建设做网络推广费用
  • 天津公司网站的建设国家职业技能培训平台
  • 动态网站建设论文余姚网站如何进行优化
  • 建设网站手机版爱站网域名查询
  • 做新闻类网站如何盈利典型的口碑营销案例
  • 网站开发可以用gif吗企业危机公关
  • 高端 网站设计公司磁力兔子
  • 重庆市建设工程监督信息网常熟seo关键词优化公司
  • 前端旅游网站行程怎么做网络营销推广案例
  • 做网站模板的软件关键词全网搜索
  • wordpress调用用户名网站seo
  • wordpress dux 增强东莞网站建设seo
  • wordpress美化底部seo入门到精通
  • 大型公司为什么做网站抖音推广
  • 制作简单的网页知乎seo