I think that there's maybe a misunderstanding. Maybe I explained the problem not too clear.
I'll try to describe it better.
So I need to insert a custom filesystem folder above the logical disks in a QTreeView using the QDirModel. That can be any user folder. For now it's a My Documents folder. I need that item to behave just like other filesystem items in the tree - expanding/collapsing, showing its contents, etc.
I agree. But unfortunately, I'm not responsible for agreeing on project requirements, and they are already approved. I have to implement the task.But you can convince your customer. Often people think and say they want something even if they don't need it.
Yes, but to leave the item empty, I need to insert it in the tree in some way at first.If it's a single item then when it is not expanded the view is useless and can be disabled or left empty
Can you please give me a hint on implementing these methods? As I understood, the main function of interest is mapToSource (). So if QDirModel stores indexes for the system logic drives as [0,1,2,...], I will need to shift them by value of 1, and when the model index equals 0, I'll need to perform some custom actions. But I can't understand how to do thisYou are looking for QAbstractProxyModel. You need to subclass it and implement mapToSource(), mapFromSource() and reimplement QAbstractItemModel::data().





Reply With Quote




Bookmarks