首页 > 代码库 > pyqt columnView例子学习

pyqt columnView例子学习

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

# python:2.x

__author__ = ‘Administrator‘

from PyQt4.QtGui import  *

from PyQt4.Qt import *

from PyQt4.QtCore import *

import sys

class Tree(QColumnView):

    def __init__(self,parnet=None,*args):

        super(Tree,self).__init__(parnet,*args)

        mode=QStandardItemModel()

        name=QStandardItem(‘name‘)

        firstName=QStandardItem(‘firstname‘)

        lastName=QStandardItem(‘lastname‘)

        name.appendRow(firstName)

        name.appendRow(lastName)

        mode.appendRow(name)

        john=QStandardItem(‘John‘)

        smit=QStandardItem(‘smith‘)

        firstName.appendRow(john)

        lastName.appendRow(smit)

        address=QStandardItem(‘address‘)

        street=QStandardItem(‘street‘)

        address.appendRow(street)

        street.appendRow(address)

        columview=QColumnView(self)

        columview.setModel(mode)

app =QApplication(sys.argv)

x = Tree()

x.show()

sys.exit(app.exec_())

如图: