I'm trying to figure out the QString::lastIndexOf and QString::chop to delete a suffix off a file, so I can add one myself. However, I get weird output that doesn't make sense to me.
Here's my test code:
QString filename = "C:/Users/Ir77/Desktop/a.png";
qDebug() << "Filename is " << filename;
QString y = '.';
int x = filename.lastIndexOf(y, -1);
qDebug() << "Last index of . is " << x;
filename.chop(x);
qDebug() << "filename is now " << filename;
And here's the qDebug() info that I get from it:
Filename is "C:/Users/Ir77/Desktop/a.png"
Last index of . is 23
filename is now "C:/U"
I'm trying to only make it delete the ".png" at the end. I have no idea where the 23 comes from.