QByteArray data; data.append("Hello, world!"); int size = data.size(); qDebug() << "Size of data:" << size;
QByteArray data; data.resize(10); data.fill('A',10); qDebug() << "Data:" << data;This example creates a QByteArray object named data and resizes it to 10 bytes using the resize() method. Then the data is filled with the character 'A' using the fill() method. The contents of the data are then printed using qDebug(). It can be seen that these examples are using the Qt framework library as the code is using classes and methods provided by Qt.