QByteArray ba = "123"; int num = ba.toInt(); // num == 123
QByteArray ba = "0x1F"; int num = ba.toInt(nullptr, 16); // num == 31In this example, a byte array is created with the value "0x1F", which represents the hexadecimal number 1F. The toInt() function is called with a base of 16 (hexadecimal), which correctly converts the byte array to an integer with the value 31. Both of these examples use the QByteArray class in the Qt framework, which means that the necessary package library is Qt.