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 SolutionsR – Displaying Hi5, Orkut, LinkedIn, and Twitter etc. Pages in Power.com website Doesn't twitter etc have their own API's that you can hook into to expose the data? e.g. http://apiwiki.twitter.com/ EDIT An API will allow you to connect to a service (Web service, REST service) to grab the data in say an XML/JSON format. You will then be able to transform this data via XSLT etc on your web page. Qt – QFile doesn’t create the file Do not hard-code this filesystem location. Instead, in Qt4 you should be using QDesktopServices: QString location = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); In Qt5, it's QStandardPaths: QString location = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); This is important because /home/username/Desktop is not guaranteed to be the user's Desktop folder. Related Topic
Best Answer
Use a
QFileInfo
to strip out the path (if any):