You Are Here:

Community: Wiki

This page was last modified on 23 November 2009, at 16:58.

Get the file information in Qt

From Forum Nokia Wiki

(Redirected from Get the file Info in Qt)



ID ... Creation date 10 June 2009
Platform S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition Tested on devices Creator IDE V 4.5 and Emulator
Category Qt for Symbian Subcategory Application


Keywords (APIs, classes, methods, functions): QFileInfo

Overview

QFileInfo class provides system-independent file information.

QFileInfo provides information about a file's name and position (path) in the file system, its access rights and whether it is a directory or symbolic link, etc. The file's size and last modified/read times are also available.

A QFileInfo can point to a file with either a relative or an absolute file path.

Preconditions


Property

  • Returns the canonical path including the file name, i.e. an absolute path without symbolic links or redundant "." or ".." elements.
str=Info->canonicalFilePath ();
  • Returns the complete base name of the file without the path.
QFileInfo fi("/tmp/archive.tar.gz");
QString base = fi.completeBaseName();  // base = "archive.tar"

Source File

Main.cpp

#include <QtGui/QApplication>
#include "fileinfo.h"
#include<QFileInfo>
#include<QWidget>
#include<QLabel>
#include<QString>
#include<QVBoxLayout>
#include<QDateTime>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *win=new QWidget();
QDateTime time;
QFileInfo info("C://demos//launcher//install.txt");
QString str=info.fileName();
time=info.lastModified();
QString str1;
str1=time.toString();
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
lay->addWidget(lbl2);//File Extension
win->setLayout(lay);
win->show();
return a.exec();
}

Screen shot

More about QFileInfo visit: QFileInfo

Image:Fileinfo.JPG

Creator IDE

Image:Fileinfo1.JPG


More about QFileInfo visit: QFileInfo

Author - User:Mind freak

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia