Solved returning list to QML
-
Hi,
I'm having trouble returning list from python to QML.
it's ok with@Property("QVariantList", notify=someNotifier)
but I can't make it work with something like@Slot(resultat=list)
orSlot(result = "QVariantList")
.
Thanks for help :-) -
Hi,
You should provide a minimal code example that shows your problem.
-
class Some(QObject): fakenotify = Signal() @Property('QVariantList', notify=fakenotify2) def withprop(self): with db_session: return self.db.Page.recents() @Slot(result=list) def withslot(self): with db_session: return self.db.Page.recents()
in some ListView using as model:
some.withprop
works
but
some.whithslot()
fails with :qrc:/qml/main.qml:54: TypeError: Cannot call method 'withslot' of null
-
Please provide a complete minimal test case including the qml you are using.
-
My bad, it's ok, I had to specify
QVariantList
in result and notlist
.