Hi everyone,

as the title says I'm trying to display 100.000.000 rows in my QTableView but I'm having some problems. When I launch my script, the widget seems to hang. After some investigations it turns out that the problem seems to be related to the headerData function which is called once for each row in the table. It does not seems to be normal, since I expect it to be called only for the currently displayed rows.
Here a test code displaying the problem:

Qt Code:
  1. import sys
  2. from PyQt4.QtCore import *
  3. from PyQt4.QtGui import *
  4.  
  5.  
  6. class MyWindow(QWidget):
  7. def __init__(self, *args):
  8. QWidget.__init__(self, *args)
  9.  
  10. # create table
  11. table = QTableView()
  12. tm = MyTableModel(self)
  13. table.setModel(tm)
  14.  
  15. # layout
  16. layout = QVBoxLayout()
  17. layout.addWidget(table)
  18. self.setLayout(layout)
  19.  
  20. class MyTableModel(QAbstractTableModel):
  21. def rowCount(self, parent):
  22. return 100000000
  23.  
  24. def columnCount(self, parent):
  25. return 10
  26.  
  27. def data(self, index, role):
  28. if not index.isValid():
  29. return QVariant()
  30. elif role != Qt.DisplayRole:
  31. return None
  32. return str((index.row(), index.column()))
  33.  
  34. def headerData(self, section, orientation, role):
  35. print "headerData", section
  36. if role == Qt.DisplayRole:
  37. return section
  38. return None
  39.  
  40. if __name__ == "__main__":
  41. app = QApplication(sys.argv)
  42. w = MyWindow()
  43. w.resize(900, 600)
  44. w.show()
  45. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode 

Anyone can point me out what I'm doing wrong? is it a bug? The test has been run on windows 7 (64 bit), PyQt 4.11.
Thanks in advance!