Skip to content

Nested QObjects and MyObjectQt API #237

Closed Answered by LeonMatthesKDAB
LeonMatthesKDAB asked this question in Ideas
Discussion options

You must be logged in to vote

Suggestion: Using Modules

Idea: Make a MyObject Module, that contains a QObject type.
That would allow for a syntax of MyObject::QObject to refer to the QObject version of the struct.

Problems:

We can't have a module that contains a struct named MyObject, as well as a module named MyObject:
e.g., this doesn't compile:

pub struct MyStruct {
    pub x: i32,
}
mod MyStruct {
    pub struct QObject {
        pub y: i32,
    }
}

Solution 1

Alternatively, we could have a MyStruct module, with a Rust and a QObject struct in it.
Even though that's also syntactically somewhat strange.

#[cxx_qt::qobject]
struct MyStruct {
    #[qproperty]
    pub x: i32
}
// replaced by cxx-qt with:
mod MyStruct {

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@LeonMatthesKDAB
Comment options

@LeonMatthesKDAB
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ahayzen-kdab
Comment options

Answer selected by ahayzen-kdab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
⬆️ feature New feature or request 🤔 discussion Feedback welcome
2 participants