以下代码貌似是一个老外写的,不知道出处了,没什么复杂的技巧,一看就懂
#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
本文介绍了一段用于Qt中QString与TCHAR类型相互转换的宏定义代码,该代码适用于Unicode与非Unicode编译环境,提供了简洁的转换方法。
3094

被折叠的 条评论
为什么被折叠?



