From the (https://qt-project.org/doc/qt-4.8/qstring.html#toWCharArray "toWCharArray") docs:

>array has to be allocated by the caller and contain enough space to hold the complete string (allocating the array with the ***same length*** as the string is always sufficient).