【Pyqt4 实例14】文件目录浏览器

  • Post author:
  • Post category:其他


#-*- coding:utf8 -*-

from PyQt4.QtCore import *
from PyQt4.QtGui import *
import math

QTextCodec.setCodecForTr(QTextCodec.codecForName("utf-8"))

if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)
    model = QDirModel()
    selModel =QItemSelectionModel(model); 
    
    list = QListView()
    tree = QTreeView()
    table = QTableView()
    
    tree.setModel(model)
    list.setModel(model)
    table.setModel(model)
    
    tree.setSelectionModel(selModel)
    list.setSelectionModel(tree.selectionModel())
    table.setSelectionModel(tree.selectionModel())
    
    QObject.connect(tree,SIGNAL("doubleClicked(QModelIndex)"),list.setRootIndex)
    QObject.connect(tree,SIGNAL("doubleClicked(QModelIndex)"),table.setRootIndex)
    
    splitter = QSplitter()
    splitter.addWidget(tree)
    splitter.addWidget(list)
    splitter.addWidget(table)
    splitter.setWindowTitle(splitter.tr("Model/View"))
    splitter.show()
    
    sys.exit(app.exec_())



版权声明:本文为cxm19830125原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。