QTreeWidget and QFileSystemModel

2019-09-06 13:29发布

Please tell me how to connect to QFileSystemModel QTreeWidget simply function SetModel() not support QFileSystemModel but only QAbstractItemModel, but I need to work with files and for these purposes QAbstractItemModel not fit, I would like to open files in directories climb QTreeWidget. Thanx

1条回答
聊天终结者
2楼-- · 2019-09-06 14:06

setModel is a private function in QTreeWidget. To use it, you could create a custom TreeWidget class that inherits QtreeWidget and QTreeView, create a public function setModel(QAbstractItemModel *model) and in it call the QTreeView setModelfunction like so:

 TreeView::setModel(QAbstractItemModel *model){
      QTreeView::setModel(model); 
 }
查看更多
登录 后发表回答