QByteArray data = "Hello, World!"; cout << data.constData(); // Output: Hello, World!
void printString(const char* str) { cout << str; } QByteArray data = "This is a test."; printString(data.constData()); // Output: This is a test.In both examples, constData() is used to get the raw data stored in the QByteArray, and this data is then used as a char* argument. The Qt library is required to use this function.