# -*- coding: utf-8 -*-

# python:2.x

__author__ = 'Administrator'

from PyQt4.QtGui import  *

from PyQt4.Qt import *

from PyQt4.QtCore import *

import sys

class Tree(QMainWindow):

def __init__(self,parnet=None):

super(Tree,self).__init__(parnet)

self.setWindowTitle('TreeWidget')

self.tree = QTreeWidget()

self.tree.setColumnCount(2)

self.tree.setHeaderLabels(['Key','Value'])

root= QTreeWidgetItem(self.tree)

root.setText(0,'root')

child1 = QTreeWidgetItem(root)

child1.setText(0,'child1')

child1.setText(1,'name1')

child2 = QTreeWidgetItem(root)

child2.setText(0,'child2')

child2.setText(1,'name2')

child3 = QTreeWidgetItem(root)

child3.setText(0,'child3')

child4 = QTreeWidgetItem(child3)

child4.setText(0,'child4')

child4.setText(1,'name4')

self.tree.addTopLevelItem(root)

self.setCentralWidget(self.tree)

app =QApplication(sys.argv)

x = Tree()

x.show()

sys.exit(app.exec_())

如图:

注:由网友提供的内容,地址:http://blog.sina.com.cn/s/blog_4b5039210100h6co.html

pyqt QTreeWidget例子学习的更多相关文章

  1. pyqt columnView例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import  * from Py ...

  2. pyqt QTableView例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import  * from Py ...

  3. pyqt QTableWidget例子学习(重点)

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from PyQ ...

  4. pyqt 托盘例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from PyQ ...

  5. pyqt 正则表达式例子学习

    def rex01(self): username=QtCore.QRegExp('[a-zA-Z0-9_]{2,10}') self.names.setValidator(QtGui.QRegExp ...

  6. pyqt tabWidget例子学习1

    from PyQt4 import QtGui from PyQt4 import QtCore from PyQt4.QtCore import pyqtSlot,SIGNAL,SLOT impor ...

  7. pyqt 配置文件例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' import sys,datetime from PyQt4.QtC ...

  8. pyqt 自定义例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' import sys from PyQt4.QtCore impor ...

  9. 数百个 HTML5 例子学习 HT 图形组件 – 3D建模篇

    http://www.hightopo.com/demo/pipeline/index.html <数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇>里提到 HT 很 ...

随机推荐

  1. Android开发所有视频教程汇总

    1.Mars的Android开发视频教程作者讲解的很详细,很全面,系统.以前出了两套视频,分别是<Java4Android视频教程>.<Android视频教程>,以及最新刚新出 ...

  2. 小结: Async & Await

    新项目组用到Async & Await, 关于Await会不会新开不开线程,遇到什么情况会新开线程的问题网上查了很多资料都没看到直观的解释.现简单总结一下. 直接上代码: namespace ...

  3. C# viewstate

    Viewstate 处理不是form中可以传值的标签 进行传值.可以禁用元素的viewstate 也可以禁用页面的Enableviewstate=”false”;(在配置区域写)内网系统,互联网后台可 ...

  4. IOS 创建App的最佳捷径

    简网App工场   ----------------创建App的最佳捷径

  5. js中完数的输出

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  6. 5 输出的properties文件按照key进行排序

    import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.FileNotFoundException; ...

  7. android控制之 adb shell (已完成,不定期增加内容)

    第一步:首先,下载adb1.0.32.zip,里面有如下图的内容: 第二步:解压缩,复制Adb.exe,和fastboot.exe到System32,注意AdbWinUsbApi.dll,AdbWin ...

  8. [Mac] 使用Mac时的一些技巧

    这篇博客就用来记录自己在使用Mac时学来的一些技巧吧! 1. 如何开启 Sticky key (在屏幕上显示输入的控制键)   就是这个东西啦,就是在视频演示的时候让别人看到自己按了什么控制键. 在s ...

  9. 转载--eclipse git插件安装

    原文地址:http://yufenfei.iteye.com/blog/1750124/ 一.Eclipse上安装GIT插件EGit Eclipse的版本eclipse-java-helios-SR2 ...

  10. web worker使用

    使用postMessage()方法传递信息.来自Worker的数据保存在event.data中.通过message和error事件与页面通信. <script> var data = [4 ...