How to inherit from Qt classes whos parent is not QObject #1311
-
I am trying the following
The problem is that QQuick3DInstancing takes a QtQuick3DObject* as a parent.
Is there any way i can use the Constructor tell it the type of the parent? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @angus-3d , Take a look at: (note: This uses the shorthand |
Beta Was this translation helpful? Give feedback.
Hi @angus-3d ,
yes, you can use the cxx_qt::Constructor trait to implement a custom constructor in Rust.
This will then overwrite the default constructor generated by CXX-Qt.
Take a look at:
https://docs.rs/cxx-qt/latest/cxx_qt/trait.Constructor.html
and the example here:
https://github.com/KDAB/cxx-qt/blob/0.7.x/examples/qml_features/rust/src/custom_parent_class.rs
(note: This uses the shorthand
cxx_qt::Initialize
to simply omit theparent
from the constructor)