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()));
    

      

  • 相关阅读:
    9.19题解
    9.18题解
    改码风
    找到了几个好的网站
    题目链接
    二分上机训练题解
    二分例题简单说明
    贪心上机训练题解
    贪心算法例题简单说明
    Johnson法则证明
  • 原文地址:https://www.cnblogs.com/fuyanwen/p/3200536.html
Copyright © 2011-2022 走看看