zoukankan      html  css  js  c++  java
  • TCHAR 转 QString wchar_t * 转QString

    #ifdef UNICODE
    
    #define QStringToTCHAR(x)     (wchar_t*) x.utf16()
    
    #define PQStringToTCHAR(x)    (wchar_t*) x->utf16()
    
    #define TCHARToQString(x)     QString::fromUtf16((x))
    
    #define TCHARToQStringN(x,y)  QString::fromUtf16((x),(y))
    
    #else
    
    #define QStringToTCHAR(x)     x.local8Bit().constData()
    
    #define PQStringToTCHAR(x)    x->local8Bit().constData()
    
    #define TCHARToQString(x)     QString::fromLocal8Bit((x))
    
    #define TCHARToQStringN(x,y)  QString::fromLocal8Bit((x),(y))
    
    #endif
    

      

    wchar_t* 转QString
    
    wchar_t* wptr = L"test";
    QString ret = QString::fromWCharArray(wptr);
    QString ret2 = QString((QChar*)wptr, wcslen(wptr));
    
    QString 转wchar_t*
    wchar_t szBuf[1024];
    QString str = tr("hello");
    wcscpy_s(reinterpret_cast<wchar_t*>(szBuf),
        sizeof(szBuf) / sizeof(wchar_t),
        reinterpret_cast<const wchar_t*>(str.utf16()));
    

      

  • 相关阅读:
    HDU_5057_分块
    HYSBZ_2002_分块
    HDU_1166_树状数组
    HDU_5692_dfs序+线段树
    多重背包
    二进制中一的个数
    康托展开
    vector, map, queue,set常用总结
    错误票据
    高精度计算
  • 原文地址:https://www.cnblogs.com/fuyanwen/p/3200536.html
Copyright © 2011-2022 走看看