QtCore.QAbstractItemModel



  • Does anyone know of an example for Python to subclass QAbstractItemModel?

    e.g. The Python documentation for QAbstractItemModel.createIndex() describes an internal pointer to the parent, but i think it is a basically lteral translation from the C++ docs. Maybe someone can help met wirth the use of QAbstractItemModel.index() and QAbstractItemModel.createIndex()?

    Cheers, Lars



  • i solved most problems i had



  • Hi! Can you post your index() method's realization, please? Right now I have issues with this. I try to pass COM object to createIndex() as ptr parameter, but Python interpreter just crashes. Here is my index() method:
    @
    def index(self, row, column, parent=QtCore.QModelIndex()):
    if parent.isValid():
    parent_item = parent.internalPointer()
    try:
    child = parent_item.ChildRows[row]
    except:
    return QtCore.QModelIndex()
    else:
    try:
    child = self.card.Sections(self.card.Type.AllSections.
    GetByAlias('Main').ID).Rows[row]
    except:
    return QtCore.QModelIndex()
    return self.createIndex(row, column, child)@

    self.card - is the COM object. I use win32com library for working with COM. Interpreter crashes when trying to execute this:
    @return self.createIndex(row, column, child)@

    Thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.