Hye everybody !
I still have a problem with my proxy.
I try to change my data root (as suggested earlier) so I redefine a new index method (to use my new data root) in my proxy as this (I repeat: it's python):
def __init__(self, model, newIndexRoot=None):
#======= Attributes Declaration =========
# We init the root of the proxy
self._data = model.getNodeFromIndex(newIndexRoot) # the data root
self._dObject = self._data.dDocObject # the dictonary of all children item
#========================================
self.setSourceModel(model)
def index(self, row, column, parent):
if not parent.isValid():
parentNode = self._data
else:
parentNode = self._dObject[parent.internalId()]
childItem = self._dObject[id(parentNode.getChildFromNum(row))]
if childItem is not None:
return self.createIndex(row, column, id(childItem))
else:
class QtgProxyModel(QtGui.QSortFilterProxyModel):
def __init__(self, model, newIndexRoot=None):
super(QtGui.QSortFilterProxyModel, self).__init__()
#======= Attributes Declaration =========
# We init the root of the proxy
self._data = model.getNodeFromIndex(newIndexRoot) # the data root
self._dObject = self._data.dDocObject # the dictonary of all children item
#========================================
self.setSourceModel(model)
def index(self, row, column, parent):
if not parent.isValid():
parentNode = self._data
else:
parentNode = self._dObject[parent.internalId()]
childItem = self._dObject[id(parentNode.getChildFromNum(row))]
if childItem is not None:
return self.createIndex(row, column, id(childItem))
else:
return QtCore.QModelIndex()
To copy to clipboard, switch view to plain text mode
But, when launch my application, it just stop. I'm running on window, and DrWatson give an unreadable report.
After debugging, the only thing I know, is that the application blow away at line 21 at the "createIndex" call.
Do I do the right thing ? If not, how should I do it (I read C++ too
)?
Is it a PyQt bug ?
Thanks
Bookmarks