Skip to content

How to use things derived from QAbstractListModel as field/property? #914

Answered by ahayzen-kdab
araraloren asked this question in Q&A
Discussion options

You must be logged in to vote

Hey,

So QML will be wanting a raw pointer in C++, eg CustomBaseClass*. We can use Rust raw pointers for this, if we look at the nested_qobjects example this is similar.

This says that there is a Q_PROPERTY which is a pointer under the field inner.

#[qobject]
#[qml_element]
#[qproperty(*mut InnerObject, inner)]
type OuterObject = super::OuterObjectRust;

Then we store a raw pointer to the QObject as a field in the struct

/// The outer QObject which has a Q_PROPERTY pointing to the in…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@araraloren
Comment options

Answer selected by araraloren
Comment options

You must be logged in to vote
4 replies
@ahayzen-kdab
Comment options

@realroot2185
Comment options

@ahayzen-kdab
Comment options

@LeonMatthesKDAB
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants