import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
def __init__(self, *args):
# create table
tm = MyTableModel(self)
table.setModel(tm)
# layout
layout.addWidget(table)
self.setLayout(layout)
def rowCount(self, parent):
return 100000000
def columnCount(self, parent):
return 10
def data(self, index, role):
if not index.isValid():
elif role != Qt.DisplayRole:
return None
return str((index.row(), index.column()))
def headerData(self, section, orientation, role):
print "headerData", section
if role == Qt.DisplayRole:
return section
return None
if __name__ == "__main__":
w = MyWindow()
w.resize(900, 600)
w.show()
sys.exit(app.exec_())
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class MyWindow(QWidget):
def __init__(self, *args):
QWidget.__init__(self, *args)
# create table
table = QTableView()
tm = MyTableModel(self)
table.setModel(tm)
# layout
layout = QVBoxLayout()
layout.addWidget(table)
self.setLayout(layout)
class MyTableModel(QAbstractTableModel):
def rowCount(self, parent):
return 100000000
def columnCount(self, parent):
return 10
def data(self, index, role):
if not index.isValid():
return QVariant()
elif role != Qt.DisplayRole:
return None
return str((index.row(), index.column()))
def headerData(self, section, orientation, role):
print "headerData", section
if role == Qt.DisplayRole:
return section
return None
if __name__ == "__main__":
app = QApplication(sys.argv)
w = MyWindow()
w.resize(900, 600)
w.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks