Version 0.8 of CXX-Qt focuses on the build system, with large internal refactors and a new API for cxx-qt-build. The new API is now considered stable. We aim to avoid backwards-incompatible changes in the future.
This new API provides a much clearer handling of Qml modules, with more options and flexibility, as they are now integrated into the main CxxQtBuilder. Many CxxQtBuilder functions can now also take configurable objects, instead of just file paths, like QmlFile instances, that allow configuring the version of the Qml component, etc. For ease-of-use, strings and lists of strings will automatically be converted to the right types in these cases. So the API is both powerful and easy to use.
Additionally, CXX-Qt projects can now span multiple crates, either by providing one QML module or QObject library per crate.
The C++ interface for each create is now defined clearer through the Interface type and allows complete control of the available header files for downstream dependencies.
Qmlls and qmllint are now also officially supported, and should work out of the box. CXX-Qt will even generate you the right configuration file by default.
Build times should now also be faster and automatic resource initialization is more stable and can be forced if necessary.
All of this is of course still integrated with CMake via cxx-qt-cmake! With CMake it is now also possible to build dynamic Qml module plugins, although we still recommend sticking with static modules by default.
Check out our examples for references of what is possible with this new release. Specifically the qml_multi_crates and qml_minimal_plugin examples show off what is possible with this new release.
Casting C++ types up and down their type hierarchy is now also possible in Rust!
This allows CXX-Qt users to express powerful APIs that can accept anything that is castable to a QObject, or any other polymorphic C++ type.
A special shout out also goes to @jnbooth, who improved and fixed many things in cxx-qt-lib and keeps pushing the API boundary of Qt in Rust!
Thanks also to everyone else who contributed and took part in the discusions on our Zulip and here on Github.
Changelog
Added
QDateTime::from_stringto parseQDateTimefrom aQString.QSet::reserveto reserve capacity up-front.- Support for further types:
QUuid - New example: Basic greeter app
- Support for further types:
qreal,qint64,qintptr,qsizetype,quint64,quintptr,QQuaternion - Support for
cfgattributes through to C++ generation - CXX-Qt-build: Improved compile time and propagation of initializers between crates
- CXX-Qt-build: Multi-crate projects are now possible with Cargo and CMake (see
examples/qml_multi_crates) - CXX-Qt-build: Allow forcing initialization of crates/QML modules (
cxx_qt::init_crate!/cxx_qt::init_qml_module!) - CXX-Qt-build:
CxxQtBuilder::filesto add multiple files - CXX-Qt-build: Allow building dynamic QML module plugins with CMake
- CXX-Qt-build: Rename
CxxQtBuilder::qobject_headertoCxxQtBuilder::cpp_fileand allow compiling .cpp files. - Add pure virtual function specified through the
#[cxx_pure]attribute - Add wrappers for up and down casting, for all types which inherit from QObject, available for &T, &mut T and Pin<&mut T>
#[base = T]is now supported inextern "C++Qt"blocks- Casting is automatically implemented for qobjects or types which have
#[base = T]in"RustQt"or"C++Qt"blocks - Support for
QMessageLogContextand sending log messages to the Qt message handler. - Serde support for further types:
QByteArray,QSet,QStringList,QVector,QUrl - Added
QEventLoopto cxx-qt-lib-extras. - Support for setting Qt log message patterns with
q_set_message_patternand formatting log messages ithq_format_log_message. - Implement
IntoIteratorfor&QHash,&QList,&QMap,&QSet, and&QVector. - Add
QByteArray:from_base64_encodingandQByteArray::to_base64. - Added support for qmllint and qmlls due to correct QML module export (qmldir, .qml files, qmltypes etc) and .qmlls.ini generation
Removed
- CXX-Qt-build: Interface no longer includes compiler definitions (https://github.com/KDAB/cxx-qt/issues/1165)
- CXX-Qt-build: Interface no longer includes initializers
- CXX-Qt-build: QML modules no longer include Rust files (use
CxxQtBuilder::filesinstead) - CXX-Qt-build: Only allow one QML module per
CxxQtBuilder - CXX-Qt-build: Make
CxxQtBuilder::cc_builderunsafe to use, to indicate its lack of guarantees