-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
6.11
-
None
Currently we need to create QObjectHolders to add the QMetaObject to a Rust structure, e.g.
let mut backend = QObjectHolder::new(Backend::default()); let _app = QGuiApplication::new(); let mut qml_engine = QQmlApplicationEngine::new(); let mut properties = QVariantMap::default(); properties.insert("backend", &backend.as_qobject_mut().into()); qml_engine.pin_mut().set_initial_properties(&properties);
The QObjectHolder consumes the Backend.
This has some drawbacks:
1) Our users need to create a QObjectHolder manually. If they do not, the application might crash.
2) The inner Backend is not accessible anymore from the Rust side. So all modifications have to be triggered from the QML side. This way it is difficult to update the UI from the Rust side, if there is no QML event involved.
It would be great if
1) We could have the QObject both on Rust and QML side at the same time. The Rust pattern for this is probably RC<>/RefCell<>.
2) The QObjectHolder is created implicitly in the QObject constructors and hidden from our users. It can be pulled out when we have to create a QVariant. This way our users do not have to deal with it and no accidents can happen.
- is required for
-
QTBUG-134769 As a dev, I need a simple way to add a Qt Quick UI to my Rust code
-
- Open
-