PDA

View Full Version : about QFileInfo



Pang
19th October 2006, 10:26
hi :
why i use the following code always get the null file name:


#include <QDir>

#include <stdio.h>

int main(int argc, char *argv[])
{
QDir dir;
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
dir.setSorting(QDir::Size | QDir::Reversed);

QFileInfoList list = dir.entryInfoList();
printf(" Bytes Filename\n");
for (int i = 0; i < list.size(); i++) {
QFileInfo fileInfo = list.at(i);
printf("%10li %s\n", fileInfo.size(), qPrintable(fileInfo.fileName()));
}
return 0;
}
please help,thanks

jpn
19th October 2006, 11:09
What about:


#include <QtDebug>
...
qDebug() << fileInfo.size() << fileInfo.fileName();