What you have there won't compile without error as C or C++. This has nothing to do with Qt once you have a char* to the data in memory:
// Create some dummy data
ba.fill(0, 10 * sizeof(float));
unsigned int size = ba.size();
char* c = ba.data();
// OR const char* cc = ba.constData();
// Make sure that ba stays in scope while you do this
// Nothing Qt below here
float* ft = reinterpret_cast<float*>(c);
// OR const float* ft = reinterpret_cast<const float*>(cc);
for (unsigned int i = 0; i < size/sizeof(float); ++i) {
std::cout << *ft++ << std:endl;
}
// Create some dummy data
QByteArray ba;
ba.fill(0, 10 * sizeof(float));
unsigned int size = ba.size();
char* c = ba.data();
// OR const char* cc = ba.constData();
// Make sure that ba stays in scope while you do this
// Nothing Qt below here
float* ft = reinterpret_cast<float*>(c);
// OR const float* ft = reinterpret_cast<const float*>(cc);
for (unsigned int i = 0; i < size/sizeof(float); ++i) {
std::cout << *ft++ << std:endl;
}
To copy to clipboard, switch view to plain text mode
The caveats regarding byte order, float/double etc still apply. If it breaks you get to keep the pieces
Bookmarks