0

I would like to save some additional data to QFileSystemModel as is file description and things like that. I already have an output window in which the user can enter some additional, not required data, but anyway I need to implement this if the users would like to add anything else than the main app allows.

Do I need to subclass QFileSystemModel and add additional data to it? How to trim new and empty lines in plainTextEditor which is used for adding additional data? How to output the data of QFileSystem to a file and then to import it back?

user1257255
  • 1,161
  • 8
  • 26
  • 55

1 Answers1

0

I would suggest creating own proxy model (based on QIdentityProxyModel).

So, you would have to reimplement data and setData roles, and so you can use those functions to obtain or save your data (using QModelIndex access).

You can associate your data with QFileSystemModel::FilePathRole filesystem's model data.

You should use some internal data structure like QVariantMap for saving data inside your model. You then can serialize this structure to file and back using QJson, for example.

Lol4t0
  • 12,444
  • 4
  • 29
  • 65