Greetings all,
eg:
QFile f("/home/umanga/Desktop/image.jpg");
How I get only the filename - "image.jpg"
Thanks in advance
Greetings all,
eg:
QFile f("/home/umanga/Desktop/image.jpg");
How I get only the filename - "image.jpg"
Thanks in advance
Use a QFileInfo
to strip out the path (if any):
QFileInfo fileInfo(f.fileName());
QString filename(fileInfo.fileName());
One approach, not necessarily the best: from a QFile
, you can get the file specification with QFile::fileName()
:
QFile f("/home/umanga/Desktop/image.jpg");
QString str = f.fileName();
then you can just use the string features like QString::split
:
QStringList parts = str.split("/");
QSTring lastBit = parts.at(parts.size()-1);