QString::toWCharArray(wchar_t * array)
其中 wchar_t * array 除了要分配內存之外,必須用 wmemset 初始化。
環境是 Visual Studio 2015.
QT官方文檔確實注明了:Note: This function does not append a null character to the array.
另一種轉換方法
auto archiveWString = mArchive.toStdWString();
auto archive = const_cast<wchar_t *>(archiveWString.c_str());
出處:VRonin https://forum.qt.io/topic/92621/convert-qstring-to-wchar_t/20