问题
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 setModel
function like so:
TreeView::setModel(QAbstractItemModel *model){
QTreeView::setModel(model);
}
来源:https://stackoverflow.com/questions/20444701/qtreewidget-and-qfilesystemmodel