[PyKDE] PyQt4 Segmentation Fault - QTableView
Andreas Pakulat
apaku at gmx.de
Tue Sep 19 17:47:13 BST 2006
On 19.09.06 08:44:32, Chris Dunscombe wrote:
> I now have a simple script to demo the seg fault:
>
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
>
> class mainWindow(QMainWindow):
> def __init__(self, parent = None):
> QMainWindow.__init__(self, parent)
> self.centralWidget = QWidget()
> self.setCentralWidget(self.centralWidget)
>
> model = QStandardItemModel(4, 2)
> tableView = QTableView()
> tableView.setModel(model)
There's your problem: The model is garbage collected at the end of
__init__. The table view's setModel function does not increment the
refcount on the model!
I don't have a copy of the PyQt4 doc's at hand, but if this is not
stated on the first page, Phil should probably add it.
I fell into this trap too, a couple of times..
Andreas
--
You will give someone a piece of your mind, which you can ill afford.
More information about the PyQt
mailing list