Closed flanfly closed 7 years ago
@flanfly Well, one of my app (it's pretty simple) Kefia
uses QListModel
as a data storage.
It uses a following approach:
list
in a Packages
struct which is essentially a QListModel
instance inside. (It is generated though Q_LIST_MODEL
macro here QPackages
(that is a wrapper on the Packages
struct).set_data
So, the QListModel
instance should be stored inside a model, but not as a property, but as a field of a struct.That is what we have for now. I hope I described it okayish.
Also, properties are supported, but it is not really comfortable to use them due to limitations of macro system on stable Rust.
Thanks for the quick answer! I did not know I have to write list
instead of QListModel
into the macro. I'll try that.
@flanfly you don't have to name it list, actually, any valid Rust identifier is good. Here are the docs with an example
I got it to work, thanks.
I'm looking into replacing qmlrs with qml-rust in one of my projects. The backend of the application exposes its data using a bunch of
QListModel
instances to the fontend written in QML. When to user kicks off an action the QML side calls a slot of a singleton object. The slot handler code on the Rust side will do his thing and then update some of theQListModel
instances and return. My problem is that I can't figure out how to get a hold of a reference to theQListModel
s. I tried to make them properties of the singleton which failed, I also had the idea to put theQmlEngine
instance into a global staticRwLock
. Any ideas?