我有QfileSysteModel和QSortFilterProxyModel。当我尝试调用QfileSysteModel.filePath
以获取文件的当前索引时,错误发生为core Dump
。这是一段代码
le = QLineEdit()
lv = QListView()
file_model = QFileSystemModel()
file_model.setRootPath(QtCore.QDir.rootPath())
proxy_model = QSortFilterProxyModel(
recursiveFilteringEnabled=True,
filterRole=QtWidgets.QFileSystemModel.FileNameRole)
proxy_model.setSourceModel(file_model)
lv.setModel(self.proxy_model)
它很好,但是当我尝试调用QFileSystemModel
Core Dumps的任何方法时。例如
filepath = file_model.filePath(lv.currentIndex())
如何使用QfileSystemModel
的任何方法