QTreeWidget and QFileSystemModel

[亡魂溺海] 提交于 2019-12-11 20:25: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:


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); 
 }


来源:https://stackoverflow.com/questions/20444701/qtreewidget-and-qfilesystemmodel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!