You Are Here:

Community: Wiki

This page was last modified on 30 October 2009, at 15:58.

How to use QDir in Qt for Symbian

From Forum Nokia Wiki


Reviewer Approved   



ID ... Creation date 10 January 2009
Platform S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition Tested on devices Emulator
Category Qt for Symbian Subcategory Dir command


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


Overview

This code snippet demonstrates how to use QDir in Qt for S60.

Preconditions

Various Function

  • This is used to filter the files that are fetched or saved.
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
  • Sets the sort order used by entryList() and entryInfoList().
dir.setSorting(QDir::Size | QDir::Reversed);
  • The function will create all parent directories necessary to create the directory.
makepath = "d://test";
dir.mkpath(makepath); 

Source Code

More About QDir visit: http://pepper.troll.no/s60prereleases/doc/qdir.html#mkpath

#include <QDir>
#include <QWidget>
#include <QVBoxLayout>
#include <QString>
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
QDir dir;
QVBoxLayout *layout = new QVBoxLayout;
QWidget *win = new QWidget;
QLabel *label = new QLabel;
QLabel *label1 = new QLabel;
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
dir.setSorting(QDir::Size | QDir::Reversed);
QString current,setpath,newdir,newpath,makepath;
makepath = "d://test";
dir.mkdir(hello);
dir.mkpath(makepath); // This command creates all sub folder to make a specific path.
newdir="mydir";
current=dir.currentPath(); // Returns the current path of the application working directory
setpath="d://test";
dir.cdUp();
dir.setPath(setpath); // Sets the path to the setpath string
newpath=dir.currentPath();
dir.mkdir(newdir); // The directory would be created in d://test
label->setText(current);
label1->setText(newpath);
layout->addWidget(label);
layout->addWidget(label1);
win->setLayout(layout);
win->show();
return app.exec();
}


Screenshot

Image:Qdir.JPG

More About QDir visit: http://pepper.troll.no/s60prereleases/doc/qdir.html#mkpath

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 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fTalkE3aE4cargeE5fscreenE5fsaverX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ