QStringList myList {"apple", "banana", "cherry", "banana", "date"}; int index = myList.findIndex("banana"); // index equals 1
QStringList myNames {"John", "Jane", "Joe", "Jenny", "Jim"}; int index = myNames.findIndex("Jennifer"); // index equals -1In this example, we create a QStringList called `myNames` with five elements. We then use the `findIndex` function to search for the first occurrence of the string "Jennifer" in `myNames`. Since "Jennifer" doesn't appear in `myNames`, the `findIndex` function returns -1 and stores it in the `index` variable. The `findIndex` function is part of the Qt Core library, which is included in the Qt framework packages.