QString str1 = "Hello"; QString str2 = "World"; int result = str1.compare(str2); // result will be less than 0
QString str1 = "Hello"; QString str2 = "HELLO"; int result = str1.compare(str2, Qt::CaseInsensitive); // result will be 0Here, we are using the optional second argument of the compare function to specify that the comparison should be case insensitive. As "Hello" and "HELLO" only differ in case, the result will be 0, indicating that the two QStrings are equal. The QString compare function is part of the Qt Core library, which is included in the Qt package.