Getting filename from path using QString basic functions

Viewed 13654

There's some path as QString:

QString path = "C:/bla/blah/x/y/file.xls";

I thought that maybe getting last offset of / would be a good start. I could then use right method (no pun intended) to get everything after that character:

path = path.right(path.lastIndexOf("/"));

or in a more compatible way:

path = path.right(std::max(path.lastIndexOf("\\"), path.lastIndexOf("/")));

Those both have the same bad result:

ah/x/y/file.xls

What's wrong here? Obviously the path is getting cut too soon, but it's even weirder it's not cut at any of / at all.

2 Answers
Related