Important: Please read the Qt Code of Conduct -

Modifying data in QByteArray

  • I have a QByteArray containing N float32 numbers and want to change some of this float32 values, for example, replace them with 0 or add some other value to it.

    QByteArray has replace() method which allows to replace given number of bytes with another data, but I can't figure out how to find starting index.

    For example, QByteArray contains 5 float32 numbers. If I want to replace 3rd float with value 3rd number + 12.5 I need to extract bytes related to the 3rd value, somehow convert them to float, add to the float value 12.5 and save result back into byte array.

    How I can implement this in a most efficient way?

  • @voltron said in Modifying data in QByteArray:

    I have a QByteArray containing N float32 numbers

    How are they encoded inside the QByteArray?

Log in to reply