重拾qt

it2022-05-05  154

最近公司又接了一个煤矿的项目,要写个小程序摘取数据,我是公司唯一c++程序员,本来搞ios搞好好的,现在又得重拾半年没摸得qt了。呵呵。。。呵呵呵。

这里只记录这次小程序的一些小的总结吧。。

1、中文字符:

函数:把一般字符串转为中文字符串:

//中文处理 QString mysqlServerTs:: handleTheChinesCode(const char*words){ QTextCodec* tc = QTextCodec::codecForLocale(); return tc->toUnicode(words); }

  

2、往txt文件里面写中文字符串:

QString strFilePath = "";//文件路径 QFile file(strFilePath); QTextStream stream(&file); stream.seek(file.size());//将当前读取文件指针移动到文件末尾 QString strTime = this->getAccurateCurrentTime(); strMes = strTime + " " + strMes; QString oStr = QObject::tr(strMes.toLatin1().data()); QByteArray bytes = QTextCodec::codecForName("UTF-8")->fromUnicode(oStr); file.write(bytes);

  

话说中文编码真心恶心

3、获取当前时间

QDateTime dt; QTime time; QDate date; dt.setTime(time.currentTime()); dt.setDate(date.currentDate()); QString currentDate = dt.toString("yyyy-MM-dd hh:mm:ss:zzz");

 

直接用QTime ::currentTime不行。

4、qt开创新线程执行也很奇葩,非要继承一个qthread类再重写run方法,不像ios直接gcd模式。。。

 

好,先写这么多,,,,

转载于:https://www.cnblogs.com/symen/p/4098633.html

相关资源:各显卡算力对照表!

最新回复(0)