ubuntu-phone team mailing list archive
-
ubuntu-phone team
-
Mailing list archive
-
Message #07909
QAbstractListModel
I'm trying to create a ListModel in Python and expose it to QML, it
looks very similar to C++, so I was wondering if anybody might know how
to get this to work.
If I create a class sub-classed from QAbstractListModel, and then try
and use an instance of it as the model in QML, the program segfaults
with no errors.
From what I can tell, this should be the minimum requirement for a
working list model:
class Addressbook(QAbstractListModel):
def __init__(self, parent=None):
super().__init__(parent)
self._addresses = ["foo", "bar", "apple"]
def rowCount(self, parent):
return len(self._addresses)
def data(self, index, role):
return self._addresses[index.row()]
The two methods don't run, but I can confirm it is instantiated by the
QML before it segfaults.
Attachment:
signature.asc
Description: This is a digitally signed message part
Follow ups