当前位置: 首页>>代码示例>>Python>>正文


Python QListView.setRootIndex方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QListView.setRootIndex方法的典型用法代码示例。如果您正苦于以下问题:Python QListView.setRootIndex方法的具体用法?Python QListView.setRootIndex怎么用?Python QListView.setRootIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QListView的用法示例。


在下文中一共展示了QListView.setRootIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DirectoryWidget

# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setRootIndex [as 别名]
class DirectoryWidget(RWidget):

    def __init__(self, parent, base="."):
        RWidget.__init__(self, parent)
        self.base = base
        self.model = QFileSystemModel()
        self.model.setRootPath(QDir.rootPath())
        self.proxyModel = FileSystemProxyModel()
        self.proxyModel.setDynamicSortFilter(True)
        self.proxyModel.setFilterKeyColumn(0)
        self.proxyModel.setSourceModel(self.model)
        
        self.listView = QListView(self)
        self.listView.setModel(self.proxyModel)
        index = self.model.index(QDir.currentPath())
        self.listView.setRootIndex(self.proxyModel.mapFromSource(index))
        self.listView.setContextMenuPolicy(Qt.CustomContextMenu)
        self.lineEdit = QLineEdit(self)
        
        filterLineEdit = QLineEdit()
        filterLabel = QLabel("Filter:")
        self.connect(filterLineEdit, SIGNAL("textChanged(QString)"), 
            self.proxyModel.setFilterWildcard)
        self.actions = []

        self.upAction = QAction("&Up", self)
        self.upAction.setStatusTip("Move to parent directory")
        self.upAction.setToolTip("Move to parent directory")
        self.upAction.setIcon(QIcon(":go-up"))
        self.upAction.setEnabled(True)
        self.actions.append(self.upAction)
        self.newAction = QAction("&New Directory", self)
        self.newAction.setStatusTip("Create new directory")
        self.newAction.setToolTip("Create new directory")
        self.newAction.setIcon(QIcon(":folder-new"))
        self.newAction.setEnabled(True)
        self.actions.append(self.newAction)
        self.synchAction = QAction("&Synch", self)
        self.synchAction.setStatusTip("Synch with current working directory")
        self.synchAction.setToolTip("Synch with current working directory")
        self.synchAction.setIcon(QIcon(":view-refresh"))
        self.synchAction.setEnabled(True)
        self.actions.append(self.synchAction)
        self.rmAction = QAction("&Delete", self)
        self.rmAction.setStatusTip("Delete selected item")
        self.rmAction.setToolTip("delete selected item")
        self.rmAction.setIcon(QIcon(":edit-delete"))
        self.rmAction.setEnabled(True)
        self.actions.append(self.rmAction)
        self.openAction = QAction("&Open", self)
        self.openAction.setStatusTip("Open selected R script")
        self.openAction.setToolTip("Open selected R script")
        self.openAction.setIcon(QIcon(":document-open"))
        self.openAction.setEnabled(True)
        self.actions.append(self.openAction)
        self.loadAction = QAction("&Load", self)
        self.loadAction.setStatusTip("Load selected R data")
        self.loadAction.setToolTip("Load selected R data")
        self.loadAction.setIcon(QIcon(":document-open"))
        self.loadAction.setEnabled(True)
        self.actions.append(self.loadAction)
        self.setAction = QAction("Set as &current", self)
        self.setAction.setStatusTip("Set folder as R working directory")
        self.setAction.setToolTip("Set folder as R working directory")
        self.setAction.setIcon(QIcon(":folder-home"))
        self.setAction.setEnabled(True)
        self.actions.append(self.setAction)
        self.loadExternal = QAction("Open &Externally", self)
        self.loadExternal.setStatusTip("Load file in external application")
        self.loadExternal.setToolTip("Load file in external application")
        self.loadExternal.setIcon(QIcon(":folder-system"))
        self.loadExternal.setEnabled(True)
        self.actions.append(self.loadExternal)
        self.rootChanged()
        
        hiddenAction = QAction("Toggle hidden files", self)
        hiddenAction.setStatusTip("Show/hide hidden files and folders")
        hiddenAction.setToolTip("Show/hide hidden files and folders")
        hiddenAction.setIcon(QIcon(":stock_keyring"))
        hiddenAction.setCheckable(True)

        self.connect(self.newAction, SIGNAL("triggered()"), self.newFolder)
        self.connect(self.upAction, SIGNAL("triggered()"), self.upFolder)
        self.connect(self.synchAction, SIGNAL("triggered()"), self.synchFolder)
        self.connect(self.rmAction, SIGNAL("triggered()"), self.rmItem)
        self.connect(self.openAction, SIGNAL("triggered()"), self.openItem)
        self.connect(self.loadAction, SIGNAL("triggered()"), self.loadItem)
        self.connect(self.loadExternal, SIGNAL("triggered()"), self.externalItem)
        self.connect(self.setAction, SIGNAL("triggered()"), self.setFolder)
        self.connect(hiddenAction, SIGNAL("toggled(bool)"), self.toggleHidden)
        self.connect(self.listView, SIGNAL("activated(QModelIndex)"), self.cdFolder)
        self.connect(self.listView, SIGNAL("customContextMenuRequested(QPoint)"), self.customContext)
        self.connect(self.lineEdit, SIGNAL("returnPressed()"), self.gotoFolder)

        upButton = QToolButton()
        upButton.setDefaultAction(self.upAction)
        upButton.setAutoRaise(True)
        newButton = QToolButton()
        newButton.setDefaultAction(self.newAction)
        newButton.setAutoRaise(True)
#.........这里部分代码省略.........
开发者ID:wioota,项目名称:ftools-qgis,代码行数:103,代码来源:widgets.py

示例2: ListViewTela

# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setRootIndex [as 别名]
tv.setModel(model)
tv.setRootIndex(parent)

lv = ListViewTela(4)
lv.setModel(model)
lv.setRootIndex(parent)

p.addTela(l)
p.addTela(tv)
p.addTela(lv)
p.show()

li = QListView()
li.setWindowTitle("ListView")
li.setModel(model)
li.setRootIndex(parent)
li.show()

t = QTableView()
t.setModel(model)
t.setWindowTitle("TableView")
t.setRootIndex(parent)
t.show()


tr = QTreeView()
tr.setModel(model)
tr.setWindowTitle("TreeView")
tr.setRootIndex(parent)
tr.show()
开发者ID:tassio,项目名称:MensageiroConsole,代码行数:32,代码来源:testeViews.py


注:本文中的PyQt4.QtGui.QListView.setRootIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。