python - How to create columns header and its labels with QTableView -


the code below creates simple qtableview header , 3 qstandarditems. question: how make header have 3 columns labeled "column 0", 'column 1" , "column 3"?

enter image description here

import os,sys pyqt4 import qtcore, qtgui app=qtgui.qapplication(sys.argv) class window(qtgui.qtableview):     def __init__(self):         super(window, self).__init__()          header=qtgui.qheaderview(qtcore.qt.horizontal, self)         self.sethorizontalheader(header)         model=qtgui.qstandarditemmodel()         in range(3):             model.appendrow(qtgui.qstandarditem('item %s'%i))         self.setmodel(model)           self.show()  window=window() sys.exit(app.exec_()) 

use

model = qtgui.qstandarditemmodel(0,3) # 3 columns  model.sethorizontalheaderlabels( [ "column 0", "column 1", "column 3"] ) 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -