[PyKDE] Problem with setModel on QTreeView
Phil Thompson
phil at riverbankcomputing.co.uk
Sun Jan 22 11:34:34 GMT 2006
On Sunday 22 January 2006 12:53 am, Andreas Pakulat wrote:
> Hi,
>
> using setModel() on a QTreeView results in the TreeView "loosing" it's
> model, if I don't save a separate reference to it. Following code
> doesn't work:
>
> tree = QtGui.QTreeView()
> tree.setModel(SomeTreeModel(tree))
> tree.show()
>
> The tree is empty, however first creating a variable pointing to the
> model and then using setModel() with that variable works.
>
> I wouldn't bother writing this if this would be the case for other
> Views too, but at least QTableView doesn't have this limitation. I don't
> need a separate reference to the model.
>
> It also shouldn't be necessary to hold a separate reference to the
> model, as QTreeView should have one internal reference to it.
The extra reference is by virtue of tree being the parent of the model, rather
than the call to setModel(). What is SomeTreeModel() derived from?
As ever, a small complete example would help.
Phil
More information about the PyQt
mailing list