[Qt-interest] Writing a table proxy model for QFileSystemModel

J-P Nurmi jpnurmi at gmail.com
Thu Jul 1 10:03:05 CEST 2010


>> <snip>
>> ...
>> QFileSystemModel *model = new QFileSystemModel(this);
>> QModelIndex idx = model->setRootPath("/tmp/test/);
>>
>> qDebug() << "rows=" << model->rowCount(idx);
>> qDebug() << "cols=" << model->columnCount(idx);
>> ...
>> </snip>
>>
>> returns:
>>
>> rows= 0
>> cols= 4
>>
>> Shouldn't it have returned "rows" as 5 (3 regular files + 2 dirs) ?
>> (I'm assuming here that the file system model stores the data in a
>> hierarchical manner, similar to the tree model shown in the examples).

Quoting QFileSystemModel docs:

"Unlike the QDirModel, QFileSystemModel uses a separate thread to
populate itself so it will not cause the main thread to hang as the
file system is being queried. Calls to rowCount() will return 0 until
the model populates a directory."

--
J-P Nurmi



More information about the Qt-interest-old mailing list