日志
-
2020-05-15 13:13
-
QString 转C++自带标准string
阅读全文»分类:QT|回复:0|浏览:363
思路:
使用QString类自带的toStdStirng()函数即可
例子std::string str;QString qStr = "两袖清风";str =qStr.toStdString();//c_str()函数返回一个指向正规C字符串的指针, 内容与本string串相同.qDebug()<<str.c_str()<<endl;12345
string 转QString
思路:
使用QString自带的静态构造函数 fromStdString(string &s)即可
例子std::string str="两袖清风";QString qStr=QString::fromStdString(str);qDebug()<<qStr.toUtf8().data()<<endl;头文件:# ..
-
2020-05-09 15:05
-
//获取当前系统语言环境,并设置语言
阅读全文»分类:QT|回复:0|浏览:633
static QString find_translation_file()
{
QString locale = QLocale::system().name(); // language code + country code (xx_XX)
QString language = locale.mid(0, 2); // language code (first two chars of locale)
QString translation_file_basename =
//QDir(Paths::translationPath()).absoluteFilePath("mystiq_");
QDir(":/translations/").absoluteFilePath("mystiq_");
// look for mystiq_xx_XX.qm in the translation directory
QString trans ..
-
2020-04-24 13:51
-
QDir dir3;
阅读全文»分类:QT|回复:0|浏览:573
//判断以参数中为路径名的路径是否存在,如果存在该路径则返回真
if(dir3.exists(Path)==NULL)
{
//该函数是创建以Path为路径的一个路径,如果父路径不存在的话,则一起同时创建;创建成功返回1,否则返回0
// dir3.mkdir(Path);
dir3.mkpath(Path);
qDebug()<<"路径创建成功";
}
else
qDebug()<<"路径已经存在";
-
2020-04-01 14:56
-
//复杂的QTJson数组QJsonArray arrays; for (int i = 0; i < 5;i++) { arrays.insert(i, QString("复杂数据组:%1").arg(image)); } QJsonObject json_ct; json_ct.insert("ct","24"); json_ct.insert("cv","10000"); QJsonObject json_albumMid; json_albumMid.insert("albumMid",QString("%1").arg(album_Mid));
阅读全文»分类:QT|回复:0|浏览:551
QJsonObject json_albumDetail; json_albumDetail.insert("module","music.musichallAlbum.AlbumInfoServer"); json_a ..
-
2019-09-24 16:50
-
//需要指定文件路径,和后缀名
阅读全文»分类:QT|回复:0|浏览:745
QString GetName::set_file_name(QString path,QString suffix_name)
{
//判断路径是否存在
QDir dir(path);
if(!dir.exists())
{
return "文件夹不存在或者路径不正确";
}
dir.setFilter(QDir::Files | QDir::NoSymLinks);
QFileInfoList list = dir.entryInfoList();
int file_count = list.count();
if(file_count <= 0)
{
return "文件不存在";
}
//开始处理
QString string_list;
for(int i=0; i<list.count();i++)
{
QFileInfo file_info = list.at(i ..
-
2019-09-11 05:21
-
###指定moc命令将含Q_OBJECT的头文件转换成标准.h文件的存放目录
阅读全文»分类:QT|回复:1|浏览:602
MOC_DIR=$$PWD/../temp/moc
RCC_DIR=$$PWD/../temp/rcc
UI_DIR=$$PWD/../temp/ui
OBJECTS_DIR=$$PWD/../temp/obj
DESTDIR=$$PWD/../temp/bin
-
2019-04-06 16:10
-
#pragma execution_character_set("utf-8")
阅读全文»分类:QT|回复:0|浏览:685
#include "frmsavelog.h"
#include <QApplication>
#include <QTextCodec>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setFont(QFont("Microsoft Yahei", 9));
#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
#if _MSC_VER
QTextCodec *codec = QTextCodec::codecForName("gbk");
#else
QTextCodec *codec = ..