QStringList fruits = {"orange", "apple", "banana", "kiwi"}; int index = fruits.indexOf("apple"); if (index != -1) { std::cout << "The index of apple is: " << index << std::endl; } else { std::cout << "The string 'apple' is not found." << std::endl; }
QString str = "The quick brown fox jumps over the lazy dog"; int index = str.indexOf("fox"); if (index != -1) { std::cout << "The index of 'fox' in the string is: " << index << std::endl; } else { std::cout << "The substring 'fox' is not found." << std::endl; }The QStringList and indexOf method are part of the Qt library for C++ development.