You can't just convert one into the other. But you can use QBuffer
as a workaround. It is a QIODevice
, so you can create a QDataStream
from it. When done writing your data, get the QByteArray
from the buffer and use its data to write to your std::ostream
.