#include#include int main() { QByteArray data(10, 'A'); data.fill('B'); qDebug() << data; return 0; } // Output: "BBBBBBBBBB"
#includeIn this example, a byte array is created with a size of 5 and filled with null bytes (0x00). The `fill` method is then used to replace all null bytes in the array with the hexadecimal value 0x55. The resulting array is printed as a hexadecimal string using the `toHex` method. The package library for QByteArray fill is Qt Core.#include int main() { QByteArray data(5, 0x00); data.fill(0x55); qDebug() << data.toHex(); return 0; } // Output: "5555555555"