Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. QtCore.QAbstractItemModel
Forum Updated to NodeBB v4.3 + New Features

QtCore.QAbstractItemModel

Scheduled Pinned Locked Moved Language Bindings
3 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    farcat
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • F Offline
      F Offline
      farcat
      wrote on last edited by
      #2

      i solved most problems i had

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dmitry.krasilnikov
        wrote on last edited by
        #3

        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!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved