PDA

View Full Version : QUrl parsing?



gfunk
17th January 2008, 02:31
I see how with QUrl, you can get the host, query string, fragment, path, authority from a given URL. Is there an easy way to get the filename from the URL? For instance, for http://doc.trolltech.com/4.3/qurl.html#path, I want just the "qurl.html" ...?

high_flyer
17th January 2008, 10:13
I am not sure, but you can try this:


QFileInfo fileInf(url.toLocalFile()); //maybe url.toString() might also be good
QString fileName = fileInf.fileName();


Or something along these lines...

wysota
17th January 2008, 10:51
Or retrieve the path(), split it on slashes and take the last component.