Replies: 1 comment 2 replies
-
Wonder if this could be linked to the QtObject and QObject trait ideas in #562 if we did it via that route. We need to consider what happens if you have a constructor with arguments though 🤔 Or would it only work for the empty arguments constructor ... |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In many cases, a non-trivial QML app will require creating a QObject that has another QObject exposed as a property. For example, in a calculator app, you might choose to implement the QML-to-C++/Rust bridge by creating a singleton
Calculator
object; however, you probably will want yourCalculator
singleton to have a propertyhistory
that stores a QAbstractListModel with the history. Unfortunately, it doesn't seem to be possible to directly set thehistory
property from Rust. Instead, you have to create a C++ factory function that returns anew HistoryModel
, which then can be used on the Rust side.It might be a good idea to create a factory function to allow allocating QObjects for situations like this. This could possibly be made opt-in via a macro or trait.
Beta Was this translation helpful? Give feedback.
All reactions