#include#include int main() { QString str = "123456789"; long num = str.toLong(); std::cout << num << std::endl; // Output: 123456789 return 0; }
#includeIn this example, we try to convert the QString "hello" to a long integer value, which is not possible. The toLong method returns 0 in this case. Package library: Qt#include int main() { QString str = "hello"; long num = str.toLong(); std::cout << num << std::endl; // Output: 0 return 0; }