Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QFlags support #1123

Open
LeonMatthesKDAB opened this issue Nov 15, 2024 · 2 comments
Open

QFlags support #1123

LeonMatthesKDAB opened this issue Nov 15, 2024 · 2 comments
Labels
🤔 discussion Feedback welcome ⬆️ feature New feature or request 🥳🎉 1.0 This issue is part of stabilization for 1.0 release

Comments

@LeonMatthesKDAB
Copy link
Collaborator

          We need to figure out a plan for QFlags maybe something with https://crates.io/crates/bitflags and https://crates.io/crates/flagset etc

Originally posted by @ahayzen-kdab in #555 (comment)

@LeonMatthesKDAB LeonMatthesKDAB added ⬆️ feature New feature or request 🥳🎉 1.0 This issue is part of stabilization for 1.0 release 🤔 discussion Feedback welcome labels Nov 15, 2024
@nicolasfella
Copy link

I played around with this and it looks rather easy.

QFlags is a class with one int member.

On the Rust side we only need

bitflags! {
    #[repr(C)]
    pub struct MyFlags: u32 {
        const A = 0x01;
        const B = 0x02;
    }
}

plus the usual ExternType boilerplate, and then it just works

@LeonMatthesKDAB
Copy link
Collaborator Author

@nicolasfella thank you for investigating.
That seems like a decent solution.

Note that this would be slightly different from how it works in Qt, where QFlags is a generic, which it wouldn't be in Rust.
But that's probably okay, as generics in CXX come with their own set of issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤔 discussion Feedback welcome ⬆️ feature New feature or request 🥳🎉 1.0 This issue is part of stabilization for 1.0 release
Projects
None yet
Development

No branches or pull requests

2 participants