qstring

How to convert QString to std::string?

丶灬走出姿态 提交于 2019-11-26 02:27:53
问题 I am trying to do something like this: QString string; // do things... std::cout << string << std::endl; but the code doesn\'t compile. How to output the content of qstring into the console (e.g. for debugging purposes or other reasons)? How to convert QString to std::string ? 回答1: One of the things you should remember when converting QString to std::string is the fact that QString is UTF-16 encoded while std::string ... May have any encodings. So the best would be either: QString qs; //

清理日志

て烟熏妆下的殇ゞ 提交于 2019-11-25 20:48:16
void checkLogsDir() { QDir dir("logs"); //创建一个dir对象 if (QDir().exists ("logs")) { QString dateDir=QDateTime::currentDateTime ().toString ("yyyyMMdd"); QDate currentDate=QDate::fromString (dateDir,"yyyyMMdd"); // List directories that match the filters. dir.setFilter (QDir::Dirs); QFileInfoList dirInfoList=dir.entryInfoList (); int count=dirInfoList.count (); //获取清理时间 uint intervalTime=settingValue ("clearLogsTime","interval",10,"common.ini").toUInt ()*24*60*60; for (int i=0; i<count; i++) { //文件信息 QFileInfo fileInfo=dirInfoList[i]; QString logsDirName=fileInfo.fileName (); //获取文件夹名称 if