Skip to content

How to inherit from Qt classes whos parent is not QObject #1311

Answered by LeonMatthesKDAB
angus-3d asked this question in Q&A
Discussion options

You must be logged in to vote

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 the parent from the constructor)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@angus-3d
Comment options

Answer selected by angus-3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants