In QDataStream there is a setIDevice(QIODevice *) method setIDevice(QIODevice *) , but there is no such method to set a QByteArray . Anyway, I did not find. I know that you can create a QDataStream object through the constructor to do this, but I already have an object, and I need to reinstall it on QByteArray . Is there any way? And if in fact there is no such method, then why? Why not?

  • aa, well, that's great.) thanks a lot !!! because I already have a QDataStream out object in that function. I did not want to create a new object, but to reconfigure the old one. - nicolai
  • You're welcome! Do not forget to mark the answer as correct!)) Good luck! - progzdeveloper

1 answer 1

Good day! And what constructors did not suit you:

QDataStream ( QByteArray * a, QIODevice::OpenMode mode ) QDataStream ( const QByteArray & a ) ?

Although in principle you can do this:

QByteArray bytes; QBuffer buffer(&bytes); QDataStream stream; stream.setDevice(&buffer);