ugly implementation to give you a little bit of a hint on how to do it.
#include <QApplication>
#include <QtGui>
//#include "main.moc"
int main(int argc, char* argv[])
{
listFiles(dir, "");
return 0;
}
{
indent += "\t";
QFileInfoList list
= dir.
entryInfoList(QDir::Files |
QDir::Dirs |
QDir::NoDotAndDotDot);
qDebug() << indent + finfo.fileName() << endl;
if (finfo.isDir()) {
listFiles
(QDir(finfo.
absoluteFilePath()), indent
);
}
}
}
#include <QApplication>
#include <QtGui>
void listFiles(QDir, QString);
//#include "main.moc"
int main(int argc, char* argv[])
{
QApplication(argc, argv);
QDir dir("mydir");
listFiles(dir, "");
return 0;
}
void listFiles(QDir directory, QString indent)
{
indent += "\t";
QDir dir(directory);
QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
foreach(QFileInfo finfo, list) {
qDebug() << indent + finfo.fileName() << endl;
if (finfo.isDir()) {
listFiles(QDir(finfo.absoluteFilePath()), indent);
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks