Modifying data in QByteArray
-
I have a
QByteArraycontaining 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.QByteArrayhasreplace()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,
QByteArraycontains 5 float32 numbers. If I want to replace 3rd float with value3rd number + 12.5I 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?
-
I have a
QByteArraycontaining 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.QByteArrayhasreplace()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,
QByteArraycontains 5 float32 numbers. If I want to replace 3rd float with value3rd number + 12.5I 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?