Hi again.<br>I have a QAbstractItemModel, as a model for a QTreeView, and have run into an issue. Trying to hide a row, but haven't had success.<br>Even with storing the QTreeVew instance in the QAbstractItemModel and then calling the view's setRowHidden() does not seem to work.<br clear="all">
<br><div>Main: <br></div><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote"> self.list = QtGui.QTreeView()<br> self.list.setModel(TreeModel(data, self.list))<br>
delegate = ViewDelegate()<br> delegate.view = self.list<br> self.list.setItemDelegate(delegate)<br> ~EntityReborn<br></blockquote><div><br>TreeModel:<br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">
class TreeModel(QtCore.QAbstractItemModel):<br> def __init__(self, data, widget, parent=None):<br> super(TreeModel, self).__init__(parent)<br> self.parentWidget = widget<br> self.rootItem = TreeItem(data, None)<br>
self.parseData(data, self.rootItem)<br></blockquote><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote"><div> </div></blockquote><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">
<div> def parseData(self, data, parent):<br> if "SubItems" in data:<br> for item in data["SubItems"]:<br> newitem = TreeItem(item, parent, parent.rootItem)<br> parent.appendChild(newitem)<br>
if not newitem.isVisible:<br> row = newitem.row()<br> index = self.createIndex(row, 0, parent)<br> self.parentWidget.setRowHidden(row, index, True)<br>
self.parseData(item, newitem) <br></div></blockquote><div> <br>TreeItem:<br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">
def __init__(self, data, parent=None, root=None):<br> super(TreeItem, self).__init__(parent)<br> ...<br> self.isVisible = True<br> if "Visible" in data:<br> self.isVisible = data["Visible"] <br>
...<br></blockquote><br>Unfortunately the actual row isn't hidden.<br></div> </div>