zoukankan      html  css  js  c++  java
  • 重拾qt

    最近公司又接了一个煤矿的项目,要写个小程序摘取数据,我是公司唯一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模式。。。

    好,先写这么多,,,,

  • 相关阅读:
    DICOMDIR结构
    给文件夹添加Everyone用户
    关于Predicate<T>委托
    开发者必备的6款源码搜索引擎
    Create XML Files Out Of SQL Server With SSIS And FOR XML Syntax
    create xml file from sql script
    DICOM中的入门概念
    小米note开启调试模式
    [转] Java基础知识——Java语言基础
    Java语言基本语法
  • 原文地址:https://www.cnblogs.com/symen/p/4098633.html
Copyright © 2011-2022 走看看