我的文件夹下面就四个文件(加上自己的文件夹应该就五个),它给我算成了21个。似乎每个文件都算了四遍。
这是怎么回事呀?大家帮忙看看吧。真不搞不懂rowCount、columnCount是怎么算的?
model = new QDirModel ;
list = new QListView(this) ;
list->setModel(model);
int stat = 1;
QModelIndex index = list->currentIndex();
if(model->isDir(index))
{
if(model->hasChildren(index))
{
row = model->rowCount(index);
column = model->columnCount(index);
for(j = row-1; j >=0 ; j--)
for(i = column-1; i >=0 ; i--)
{
child_index = model->index(j,i,index);
filename = model->fileName(child_index);
if(child_index.isValid()&& !filename.isEmpty())
{
child_info = model->fileInfo(child_index) ;
child_size = child_info.size ();
size += child_size;
stat++;
}
}
}
}