Skip to content

Constructor trait to allow non-Default QObjects #339

Discussion options

You must be logged in to vote

We can expand this to fix a few issues:

  • Routing of arguments to parent class, also make sure not to require Copy on the arguments
  • Allow different argument types for parent class, base class and initialize
// auto-generate this trait impl for any qobject::T
trait QObject {
    type Inner;
}

trait Constructor<Args>: QObject {
    type ConstructArguments = Args;
    type initializeArguments = ();
    type BaseArgs = (*mut QObject);

    fn route_args(args: Args) -> (ConstructArguments, InitializeArguments, baseArgs) {
        (args, (), (nullptr))
    }

    fn construct(args: ConstructArguments) -> <Self as QObject>::Inner {
        Default::default()
    }

    fn intialize(self: Pin<&mut 

Replies: 4 comments 1 reply

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

Comment options

You must be logged in to vote
0 replies
Answer selected by LeonMatthesKDAB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants