// Initialization QByteArray data("hello world"); QByteArray binaryData = QByteArray::fromHex("68656C6C6F20776F726C64"); // Appending data.append("!"); data += " :)"; // Inserting data.insert(5, " there"); // Removing data.remove(5, 5); // Converting int num = data.toInt(); // Converts “hello” to 542393671 QString text = data; // Converts to a QString object // Iterating for (char c : data) { // do something with each character } // Reading/writing files QFile file("test.bin"); if (file.open(QIODevice::ReadWrite)) { QByteArray contents = file.readAll(); file.write(binaryData); file.close(); }This code makes use of the Qt library, specifically the QtCore module, which provides the QByteArray class among other utility classes for working with data.