[PyQt] Hiding a row in a QAbstractItemModel
Entity Reborn
entityreborn at gmail.com
Mon Feb 14 00:07:41 GMT 2011
Hi again.
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.
Even with storing the QTreeVew instance in the QAbstractItemModel and then
calling the view's setRowHidden() does not seem to work.
Main:
> self.list = QtGui.QTreeView()
> self.list.setModel(TreeModel(data, self.list))
> delegate = ViewDelegate()
> delegate.view = self.list
> self.list.setItemDelegate(delegate)
> ~EntityReborn
>
TreeModel:
> class TreeModel(QtCore.QAbstractItemModel):
> def __init__(self, data, widget, parent=None):
> super(TreeModel, self).__init__(parent)
> self.parentWidget = widget
> self.rootItem = TreeItem(data, None)
> self.parseData(data, self.rootItem)
>
>
def parseData(self, data, parent):
> if "SubItems" in data:
> for item in data["SubItems"]:
> newitem = TreeItem(item, parent, parent.rootItem)
> parent.appendChild(newitem)
> if not newitem.isVisible:
> row = newitem.row()
> index = self.createIndex(row, 0, parent)
> self.parentWidget.setRowHidden(row, index, True)
> self.parseData(item, newitem)
>
TreeItem:
> def __init__(self, data, parent=None, root=None):
> super(TreeItem, self).__init__(parent)
> ...
> self.isVisible = True
> if "Visible" in data:
> self.isVisible = data["Visible"]
> ...
>
Unfortunately the actual row isn't hidden.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110213/5727a817/attachment.html>
More information about the PyQt
mailing list