Get filename from QFile?

Viewed 73603

eg:

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

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

4 Answers

I use this:

bool utes::pathsplit(QString source,QString *path,QString *filename)
{
QString fn;
int index;
    if (source == "") return(false);
    fn = source.section("/", -1, -1);
    if (fn == "") return(false);
    index = source.indexOf(fn);
    if (index == -1) return(false);
    *path = source.mid(0,index);
    *filename = fn;
    return(true);
}
Related