The columns of my table do not resize to contents until you scroll to an item requiring the column be expanded AND resize the splitter pane. Resizing the entire window has the same effect as it also resizes the splitter. My table requires persistent editors, and you will see at row 16 there is a table with 50 columns, which should...after calling 'resizeColumnsToContents' determine the width of column 0. However it will not resize until you scroll down to it and trigger a splitter resize.

Qt Code:
  1. from PyQt4 import QtCore,QtGui
  2. import sys
  3.  
  4. app = QtGui.QApplication(sys.argv)
  5. mw = QtGui.QMainWindow()
  6. spl = QtGui.QSplitter()
  7. spl.addWidget(QtGui.QLabel('Filler'))
  8.  
  9. # create table
  10. class tbl(QtGui.QTableWidget):
  11. def __init__(self):
  12. super(tbl,self).__init__()
  13. self.setRowCount(20)
  14. self.setColumnCount(2)
  15. self.horizontalHeader().setStretchLastSection(False)
  16. self.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents)
  17. self.verticalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents)
  18. self.setItemDelegate(delg(self))
  19.  
  20. # persist editors
  21. for x in xrange(0,self.rowCount()):
  22. for y in xrange(0,self.columnCount()):
  23. self.setItem(x,y,QtGui.QTableWidgetItem('test'))
  24. for x in xrange(0,self.rowCount()):
  25. for y in xrange(0,self.columnCount()):
  26. self.openPersistentEditor(self.item(x,y))
  27. self.resizeColumnsToContents()
  28.  
  29. # create item delegate
  30. class delg(QtGui.QItemDelegate):
  31. def __init__(self,parent):
  32. super(delg,self).__init__(parent)
  33.  
  34. def createEditor(self,parent,option,index):
  35. if index.column() == 1:
  36. return QtGui.QLineEdit(parent=parent)
  37. if index.row() == 15:
  38. t = QtGui.QTableWidget(parent=parent)
  39. t.setRowCount(5)
  40. t.setColumnCount(50)
  41. return t
  42. return QtGui.QLineEdit(parent=parent)
  43.  
  44. t = tbl()
  45. spl.addWidget(t)
  46. mw.setCentralWidget(spl)
  47.  
  48. # add and show
  49. mw.show()
  50. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode 

Is there a way to force the table to respect the size of all columns? I have tried overwriting the minimumSizeHint for the editor table but get quirky results, eg: the second column will be painted ontop of the editor table....until I resize the splitter which triggers something....a repaint?