Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
Get the file information in Qt
This article shows how to use QFileInfo to get name and modification information about a file in the file system. QFileInfo objects are used to hold information about files and directories.
The method used in the case are given below :
- fileName() : Returns the name of the file, excluding the path.
- lastModified() :Returns the date and time when the file was last modified.
- suffix() : Returns the suffix of the file.The suffix consists of all characters in the file after (but not including) the last '.'.
- Download and install the Qt SDK.
- Returns the canonical path including the file name, i.e. an absolute path without symbolic links or redundant "." or ".." elements.
- Returns the complete base name of the file without the path.
QFileInfo fi("/tmp/archive.tar.gz"); QString base = fi.completeBaseName(); // base = "archive.tar"
int main(int argc, char *argv)
QApplication a(argc, argv);
QWidget *win=new QWidget();
QString ext = info.suffix();
QLabel *lbl=new QLabel(str);
QLabel *lbl1=new QLabel(str1);
QLabel *lbl2=new QLabel(ext);
QVBoxLayout *lay=new QVBoxLayout();
lay->addWidget(lbl);// Name of file "Intall.txt"
lay->addWidget(lbl1);//Last Modified Date
Author - User:Mind freak