Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1877

Exposing QAbstractItemModel as Qt property to QML is confusing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3: Somewhat important P3: Somewhat important
    • 6.8.0, 6.7.3
    • 6.2.4
    • PySide
    • None
    • All
    • 8c92fc7442da76d856f29c394d727f34170cde6d, 9b17919d6f8bb3d6207b6baea9e8c9ac9229de1f

      Trying to expose a QAbstractItemModel derived class as a property from Python to QML is somewhat confusing.

      When choosing the model's class type or QAbstractItemModel as the property type, the QML engine throws an error along the lines of QMetaProperty::read: Unable to handle unregistered datatype 'QAbstractListModel*' for property 'LockHandler::qmlModel'.

      One would expect this to work, since QAbstractItemModel is a QObject derived class.

      Instead, exposing the model a QObject or QVariant type property leads to the correct results.

      I attached an example program which shows different ways of exposing the model to QML and what is seen from QML.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            kleint Friedemann Kleint
            strahlex Alexander Rössler
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes