PDA

View Full Version : QString::indexOf Qt::CaseInsensitive



Carlsberg
19th May 2009, 06:27
Hello,

Ca anyone explain me if indexOf() is bugged or has a meaning I don't really understand?

For example



QString str = "Splash Screen";
QString pattern = "SCreen";

int i = str.indexOf(pattern, Qt::CaseInsensitive);
cout << i << endl;


will print -1, I say it should print 7

On the other hand contains() works ok



bool b = str.contains(pattern, Qt::CaseInsensitive);
cout << b << endl;


this will return TRUE

caduel
19th May 2009, 07:32
QString::indexOf() takes case-sensitivity as its 3rd argument, the 2nd is the start-offset to start the search...

HTH

Carlsberg
19th May 2009, 09:59
lol. I'm going now to check my eyes :cool:

lyuts
19th May 2009, 18:11
I think that even with correct indexOf call it should return you -1.

You have


QString str = "Splash Screen";
QString pattern = "SCreen";


and obviously "SCreen" is not a part of "SplashScreen".