[PyQt] Using a protected slot (columnResized)

Andreas Pakulat apaku at gmx.de
Thu Dec 27 20:35:34 GMT 2007


On 27.12.07 15:27:20, Noam Raphael wrote:
> 2007/12/26, Andreas Pakulat <apaku at gmx.de>:
> > Then you need to provide a minimal self-contained example that
> > demonstrates the problem.
> >
> No problem at all:
> 
> http://python.pastebin.com/f1ac4e258
> 
> It creates a table which does nothing when you resize a column...

Hmm, it works as soon as you put the method into a subclass of
QTableView. So either this is not supported by PyQt4, or there's a bug.
If Phil doesn't come back to this thread until sometime in early january
I suggest to send a new mail with the above example and this code which
works fine:

,----[ testtab.py ]-
| #!/usr/bin/env python
|  
| import sys
| from PyQt4 import QtCore, QtGui
| from PyQt4.QtCore import Qt
|  
| 
| 
| class MyWidget(QtGui.QTableView):
| 	def __init__(self):
| 		QtGui.QTableView.__init__(self, None)
| 		self.connect(self.horizontalHeader(), QtCore.SIGNAL("sectionResized(int,int,int)"), self.columnResized)
| 	def columnResized(*args):
| 		print args
| 
| 
| def main():
|     app = QtGui.QApplication(sys.argv)
|  
|     model = QtGui.QStandardItemModel(3,3)
|     tableView = MyWidget()
|     tableView.setModel(model)
|     tableView.show()
|     sys.exit(app.exec_())
|  
| if __name__ == '__main__':
|     main()
`----

Andreas

-- 
You are scrupulously honest, frank, and straightforward.  Therefore you
have few friends.


More information about the PyQt mailing list