pyqt QTableView例子学习

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

# python:2.x

__author__ = ‘Administrator‘

from PyQt4.QtGui import  *

from PyQt4.Qt import *

from PyQt4.QtCore import *

import sys

class Tree(QTableView):

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

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

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

mode1=QStandardItemModel()

mode1.setColumnCount(2)

mode1.setRowCount(2)

mode1.setHeaderData(0,Qt.Horizontal,(u‘姓名‘))

mode1.setHeaderData(1,Qt.Horizontal,(u‘成绩‘))

self.setModel(mode1)

mode1.setItem(0,0,QStandardItem(‘999‘))

mode1.setItem(1,0,QStandardItem(‘9‘))

mode1.setItem(0,1,QStandardItem(‘hehe‘))

mode1.setItem(1,1,QStandardItem(‘hehe1‘))

app =QApplication(sys.argv)

x = Tree()

x.show()

sys.exit(app.exec_())

如图:

pyqt QTableView例子学习

时间: 2024-10-14 20:00:29

pyqt QTableView例子学习的相关文章

pyqt QTableWidget例子学习(重点)

# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from PyQt4.Qt import * from PyQt4.QtCore import * lista = ['aa', 'ab', 'ac'] listb = ['ba', 'bb', 'bc'] listc = ['ca', 'cb', 'cc'] mystruct = {'A':lista, 'B':

pyqt 正则表达式例子学习

def rex01(self): username=QtCore.QRegExp('[a-zA-Z0-9_]{2,10}') self.names.setValidator(QtGui.QRegExpValidator(username,self)) mainname=QtCore.QRegExp("^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$") self.mains.setValidator(QtGui.QRegExpValidator(mainnam

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,

pyqt 托盘例子学习

# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from PyQt4.Qt import * from PyQt4.QtCore import * from tp import Ui_Form import sys from PyQt4.QtCore import Qt QTextCodec.setCodecForTr(QTextCodec.codecForNa

pyqt tabWidget例子学习1

from PyQt4 import QtGui from PyQt4 import QtCore from PyQt4.QtCore import pyqtSlot,SIGNAL,SLOT import sys class myTabWidget(QtGui.QTabWidget): def tabChangedSlot(self,argTabIndex): QtGui.QMessageBox.information(self,"Tab Index Changed!", "C

pyqt QTreeWidget例子学习

# -*- 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.

pyqt 配置文件例子学习

# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' import sys,datetime from PyQt4.QtCore import Qt from PyQt4 import QtGui,QtCore,Qt from aa import Ui_Form class Example(QtGui.QDialog,Ui_Form): def __init__(self,parnet=None): super(Exa

pyqt 自定义例子学习

# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' import sys from PyQt4.QtCore import Qt from PyQt4 import QtGui,QtCore,Qt from about import Ui_Form class Example(QtGui.QDialog,Ui_Form): def __init__(self,parnet=None): super(Example, 

pyqt标签例子学习

import sys from PyQt4 import QtGui def main(): app=QtGui.QApplication(sys.argv) window=QtGui.QWidget() window.setWindowTitle(u'标签') tab1=QtGui.QScrollArea() tab_layout=QtGui.QVBoxLayout(tab1) test1=QtGui.QTextBrowser() tab_layout.addWidget(test1) tab