I want to know how can i relase QByteArray and QByteStream from QT specialy at this snippet code:
QByteArray DicResourceByteArray;
QDataStream out(&DicResourceByteArray, QIODevice::WriteOnly);
QString encoded;
out.writeRawData(DicBlock.data + pos, DicBlock.length - pos);
encoded = QString(DicResourceByteArray.toBase64());
All will be released automatically as soon as will run out of scope according to RAII concept. If you want to release memory explicitly, call something like clear()
but that is unneeded - all cleaning will be done in QByteArray
's destructor. With QDataStream situation is the same... Also note that this is strongly preferrable coding style - when you will create your own classes try to do the same. It saves a lot of headache with managing C-like pointers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With