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.
signature.asc
Description: This is a digitally signed message part
-- Mailing list: https://launchpad.net/~ubuntu-phone Post to : [email protected] Unsubscribe : https://launchpad.net/~ubuntu-phone More help : https://help.launchpad.net/ListHelp

