本文整理汇总了Python中PyQt5.QtWidgets.QFileSystemModel.setReadOnly方法的典型用法代码示例。如果您正苦于以下问题:Python QFileSystemModel.setReadOnly方法的具体用法?Python QFileSystemModel.setReadOnly怎么用?Python QFileSystemModel.setReadOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QFileSystemModel
的用法示例。
在下文中一共展示了QFileSystemModel.setReadOnly方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AssetBrowser
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import setReadOnly [as 别名]
class AssetBrowser(QMainWindow, Ui_MainWindow):
asset_clicked = pyqtSignal(str, str, name='assetClicked')
def __init__(self):
super(AssetBrowser, self).__init__()
self.setupUi(self)
self.dir_model = QFileSystemModel()
self.dir_model.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs)
self.dir_model.setReadOnly(False)
self.dir_view.setModel(self.dir_model)
self.dir_view.hideColumn(1)
self.dir_view.hideColumn(2)
self.dir_view.hideColumn(3)
self.file_model = QFileSystemModel()
self.file_model.setFilter(QDir.NoDotAndDotDot | QDir.Files)
self.file_model.setReadOnly(False)
self.file_view.setModel(self.file_model)
def open_project(self, project_dir):
path = os.path.join(project_dir)
self.dir_model.setRootPath(path)
self.file_model.setRootPath(path)
self.dir_view.setRootIndex(self.dir_model.index(path))
self.file_view.setRootIndex(self.file_model.index(path))
def dir_clicked(self, idx):
path = self.dir_model.fileInfo(idx).absoluteFilePath()
self.file_view.setRootIndex(self.file_model.setRootPath(path))
def file_doubleclicked(self, idx):
fileinfo = self.file_model.fileInfo(idx)
path = fileinfo.absoluteFilePath()
ext = fileinfo.suffix()
self.asset_clicked.emit(path, ext)
示例2: AssetBrowser
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import setReadOnly [as 别名]
class AssetBrowser(QMainWindow, Ui_MainWindow, PlaygroundModule):
Name = "asset_browser"
def __init__(self, module_manager):
super(AssetBrowser, self).__init__()
self.setupUi(self)
self.init_module(module_manager)
self.dir_model = QFileSystemModel()
self.dir_model.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs)
self.dir_model.setReadOnly(False)
self.dir_view.setModel(self.dir_model)
self.dir_view.hideColumn(1)
self.dir_view.hideColumn(2)
self.dir_view.hideColumn(3)
self.file_model = QFileSystemModel()
self.file_model.setFilter(QDir.NoDotAndDotDot | QDir.Files)
self.file_model.setReadOnly(False)
self.file_view.setModel(self.file_model)
self.dock = self.modules_manager.new_docked(self, self.Name, "Asset browser",
Qt.BottomDockWidgetArea)
self.modules_manager.main_window.splitDockWidget(self.dock,
self.modules_manager["asset_view"].dock, Qt.Horizontal)
def on_open_project(self, project):
project_dir = project.project_dir
path = os.path.join(project_dir)
self.dir_model.setRootPath(path)
self.file_model.setRootPath(path)
self.dir_view.setRootIndex(self.dir_model.index(path))
self.file_view.setRootIndex(self.file_model.index(path))
def dir_clicked(self, idx):
path = self.dir_model.fileInfo(idx).absoluteFilePath()
self.file_view.setRootIndex(self.file_model.setRootPath(path))
def file_doubleclicked(self, idx):
fileinfo = self.file_model.fileInfo(idx)
path = fileinfo.absoluteFilePath()
ext = fileinfo.suffix()
asset_name = path.replace(self.project_manager.project_dir, '').replace('/src/', '').split('.')[0]
self.modules_manager.open_asset(path, asset_name, ext)
def file_clicked(self, idx):
fileinfo = self.file_model.fileInfo(idx)
path = fileinfo.absoluteFilePath()
ext = fileinfo.suffix()
asset_name = path.replace(self.project_manager.project_dir, '').replace('/src/', '').split('.')[0]
self.modules_manager.show_asset(path, asset_name, ext)