Qt – Get filename from QFile

qtqt4

eg:

QFile f("/home/umanga/Desktop/image.jpg");

How I get only the filename – "image.jpg"?

Best Answer

Use a QFileInfo to strip out the path (if any):

QFileInfo fileInfo(f.fileName());
QString filename(fileInfo.fileName());
Related Topic