Answer the question
In order to leave comments, you need to log in
IndexOf bug or misuse?
Here is the code:
QString fakePath="c:/test/test.mp3";
int pos = fakePath.indexOf(QString("."),-1);
qDebug("pos=%d\n",pos);
If from is -1, the search starts at the last character; if it is -2, at the next to last character and so on.
Answer the question
In order to leave comments, you need to log in
indexOf searches for an occurrence starting at the position specified by the second argument. She is always looking forward, i.e. to the right. Because you set the initial position to -1, then it will search starting from the character "3" and further to the right. Naturally, there is no point there and the function will rightly return -1 (not found).
And what, in fact, did you expect the result with such arguments?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question