<span style>Oops!</span><div style>Sorry, I forgot completely about that piece of code.</div><div style>The TreeModel class code is found below:</div><div style><br></div><div style><div>class TreeModel(QAbstractItemModel):</div>
<div><br></div><div> def columnCount(self, parent):</div><div> if parent.isValid():</div><div> return parent.internalPointer().columnCount()</div><div> else:</div><div> return self.rootItem.columnCount()</div>
<div><br></div><div> def get_item(self, index):</div><div> if not index.isValid():</div><div> return None</div><div> item = index.internalPointer()</div><div> return item</div><div><br></div>
<div> def data(self, index, role=Qt.DisplayRole):</div><div> if not index.isValid():</div><div> return None</div><div> if role != Qt.DisplayRole:</div><div> return None</div><div> item = index.internalPointer() </div>
<div> data = item.data(index.column())</div><div> return data</div><div><br></div><div> def flags(self, index):</div><div> if not index.isValid():</div><div> return Qt.NoItemFlags</div><div>
return Qt.ItemIsEnabled | Qt.ItemIsSelectable</div><div><br></div><div> def headerData(self, section, orientation, role):</div><div> if orientation == Qt.Horizontal and role == Qt.DisplayRole:</div><div>
return self.rootItem.data(section)</div><div> return None</div><div><br></div><div> def index(self, row, column, parent):</div><div> if not self.hasIndex(row, column, parent):</div><div> return QModelIndex()</div>
<div> if not parent.isValid():</div><div> parentItem = self.rootItem</div><div> else:</div><div> parentItem = parent.internalPointer()</div><div> childItem = parentItem.child(row)</div>
<div> if childItem:</div><div> return self.createIndex(row, column, childItem)</div><div> else:</div><div> return QModelIndex()</div><div><br></div><div> def parent(self, index):</div>
<div> if not index.isValid():</div><div> return QModelIndex()</div><div> childItem = index.internalPointer()</div><div> parentItem = childItem.parent()</div><div> if parentItem == self.rootItem:</div>
<div> return QModelIndex()</div><div> return self.createIndex(parentItem.row(), 0, parentItem)</div><div><br></div><div> def rowCount(self, parent):</div><div> if parent.column() > 0:</div><div>
return 0</div><div> if not parent.isValid():</div><div> parentItem = self.rootItem</div><div> else:</div><div> parentItem = parent.internalPointer()</div><div> return parentItem.childCount()</div>
<div><br></div><div>Many thanks,</div><div>Gabriel</div></div><br><div class="gmail_quote">On Fri, Jan 13, 2012 at 12:13 PM, Benjamin Kloster <span dir="ltr"><<a href="mailto:benjamin.kloster@videlco.eu">benjamin.kloster@videlco.eu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Without the lsfw2 module, it's hard to test on my end, but have you tried keeping around a reference to the sourceModel? The Qt documentation doesn't mention whether the proxy model assumes ownership. If it doesn't, the source model will be garbage collected.<br>
______________________________<u></u>_________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.<u></u>com/mailman/listinfo/pyqt</a><br>
</blockquote></div><br>