How to store custom data inside each index in QFileSystemModel
Hi,
I have QFileSystemModel and I want to store some additional data in each index.
I used setData function like as
Code:
model.setData(index, "additional data", Qt::UserRole);
but when I try take these custom data by means of command
Code:
qDebug()<< model.index(0, 0, parent).data(Qt::UserRole);
it return invalid QVariant, why? QFileSystemModel does not contain container for custom data? If not then I have to inherit from file system model and store it myself?
For example inside my custom delegate if index represents file I need take size of that file. If index represents folder I want take count of files inside this folder and some more information. How I can this done?
Regards,
Re: How to store custom data inside each index in QFileSystemModel
Quote:
Originally Posted by
Scope
it return invalid QVariant, why? QFileSystemModel does not contain container for custom data?
I doubt that the model can store data, its purpose is to present the file system data in the Qt model interface.
Quote:
Originally Posted by
Scope
If not then I have to inherit from file system model and store it myself?
That sounds like a valid approach.
Alternatively you could use a QIdentityProxyModel based proxy
Cheers,
_