I have a file name into a QByteArray
QString file_name = "icon.jpg";
QByteArray qba1; qba+=file_name;
I have the contents of a file into a QByteArray
QFile file("C:\\Devel\\icon.jpg");
if (file.open(QIODevice::ReadOnly)){
QByteArray content = file.readAll();
}
- How to connect the file name and the contents of one variable of type QByteArray?
- How to parse this variable QByteArray back to file name and content?
Simplest way is to start with the length of the filename, then the filename itself, followed by the data. Parsing the data back is as simple as reading the filename-length first, read the filename, then the data.