-
Notifications
You must be signed in to change notification settings - Fork 78
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
Add support for C++ QML Elements in CxxQtBuilder #1146
base: main
Are you sure you want to change the base?
Conversation
- Introduce qml_qobjects field to CxxQtBuilder struct - Implement qml_qobject method for adding QML QObject files - Process QML QObjects in build method, including moc generation - Include generated metatypes.json for QML module support - Update rerun-if-changed cargo instructions for added files
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1146 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 71 71
Lines 11967 11967
=========================================
Hits 11967 11967 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this deserves a mention in CHANGELOG.md, can you add it to the MR?
/// Specify a C++ header and source file containing a Q_OBJECT macro to run [moc](https://doc.qt.io/qt-6/moc.html) on. | ||
/// Unlike [CxxQtBuilder::qobject_header], it includes the generated metatypes.json, so that C++ classes can be included | ||
/// in QML modules. | ||
pub fn qml_qobject( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cpp_qobject
? I guess this could have other applications outside of QML
Hi @akiselev , I'm okay with the "list of tuples" approach you have in your initial comment. Please note that for version 0.8 we are planning a larger refactor of the build system, which will likely end up supporting what you're currently asking anyway due to the nature of the proposed architecture. |
This PR is a WIP to add support for registering classes implemented in C++ with a QML module so that they can be included in Cargo-only builds. Instead of just running
moc
on a header, it also includes the generated metatype information which is needed to register the C++ QML elements.This first implementation is one I wrote to unblock my own project so I'd appreciate some advice for how to integrate this properly into
cxx-qt-build
. It should probably be another property on QmlModule like so, but I couldn't figure out how to best implement it that way:With @LeonMatthesKDAB's temporary fix found in #1135, it correctly includes C++ QML elements in modules built with Cargo only.