You can assign the value in str to size with:

QByteArray ar = str.toAscii(); // or toLatin1 or toLocal8Bit
size = ar.data();

However, size will be referencing the bytes in the QByteArray object and will go "poof" if/when the QByteArray is destructed.

Otherwise, you can do:

QByteArray ar = str.toAscii();
size = new char[ar.count() + 1];
memcpy(size, ar.constData(), ar.count() + 1);

and then size will "own" its own copy of the data (and it will need to be explicitly deleted later).