Skip to content

Releases: KDAB/cxx-qt

0.8.0 - Build System Stabilization 🔨

18 Dec 15:21
05fdfdc

Choose a tag to compare

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_string to parse QDateTime from a QString.
  • QSet::reserve to 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 cfg attributes 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::files to add multiple files
  • CXX-Qt-build: Allow building dynamic QML module plugins with CMake
  • CXX-Qt-build: Rename CxxQtBuilder::qobject_header to CxxQtBuilder::cpp_file and 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 in extern "C++Qt" blocks
  • Casting is automatically implemented for qobjects or types which have #[base = T] in "RustQt" or "C++Qt" blocks
  • Support for QMessageLogContext and sending log messages to the Qt message handler.
  • Serde support for further types: QByteArray, QSet, QStringList, QVector, QUrl
  • Added QEventLoop to cxx-qt-lib-extras.
  • Support for setting Qt log message patterns with q_set_message_pattern and formatting log messages ith q_format_log_message.
  • Implement IntoIterator for &QHash, &QList, &QMap, &QSet, and &QVector.
  • Add QByteArray:from_base64_encoding and QByteArray::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 (#1165)
  • CXX-Qt-build: Interface no longer includes initializers
  • CXX-Qt-build: QML modules no longer include Rust files (use CxxQtBuilder::files instead)
  • CXX-Qt-build: Only allow one QML module per CxxQtBuilder
  • CXX-Qt-build: Make CxxQtBuilder::cc_builder unsafe to use, to indicate its lack of guarantees

0.7.3

02 Oct 09:29

Choose a tag to compare

Fixed

  • Fix QEnum generation for Qt 6.9.2+

0.7.2

29 Apr 06:42

Choose a tag to compare

What's Changed

Added

  • impl cxx_qt::Initialize for X {} as shorthand for impl cxx_qt::Constructor<()> for X {}
  • extern "RustQt" blocks no longer have to be marked unsafe

Fixed

  • cxx-qt-build: Use shorter paths to avoid file path length limitations on Windows
  • CMake: Use Release Qt DLLs and runtime for MSVC Debug builds
  • Fix some generated links to book page
  • #[inherit] attributes are no longer ignored in extern "C++Qt" blocks - they now trigger an error

Full Changelog: v0.7.1...v0.7.2

0.7.1

05 Mar 12:25

Choose a tag to compare

⚠️ We changed the versioning scheme for cxx-qt-cmake for this release!

The GIT_TAG for this release is 0.7.1, (and not v0.7.1).
We will no longer use the v prefix for cxx-qt-cmake releases going forward.

We have chosen to make this change for two reasons:

  1. It's now consistent with version declarations in Cargo, which don't use the v prefix
  2. As the name is now consistent with our 0.7 branch name, you can use GIT_TAG 0.7 to simply follow the latest patch release, similar to specifying "0.7" in Cargo.toml.

Added

  • Allow creating a QImage from an image::RgbaImage.

Fixed

  • Prevent clippy from tripping lint
  • Build warnings due to unused unsafe blocks since CXX 1.0.130
  • On non-Unix platforms, use deep copying rather than symlinking
  • cxx-qt-cmake: Fix build errors with rustup 1.28.0 by bumping Corrosion

0.7.0

30 Oct 17:39

Choose a tag to compare

Added

  • #[auto_cxx_name] and #[auto_rust_name] attributes for extern blocks, which will convert the case of names, automatically camelCase for cxx, and snake_case for rust
  • Support for further types: QLine, QLineF, QImage, QPainter, QFont, QPen, QPolygon, QPolygonF, QRegion, QAnyStringView
  • internal_pointer_mut() function on QModelIndex
  • c_void in CXX-Qt-lib for easy access to void *
  • CxxQtThread is now marked as Sync so that it can be used by reference
  • Add cxx-qt-lib-extras crate which contains: QCommandLineOption, QCommandLineParser, QElapsedTimer, QApplication
  • Serde support for QString (requires "serde" feature on cxx-qt-lib)
  • A new QuickControls module, which exposes QQuickStyle. This module is enabled by default and is behind the qt_quickcontrols feature.
  • Add support for specifying read write and notify in qproperty macro, including support for custom user defined functions
  • Add support for the constant, required, reset and final flags in the qproperty macro
  • QObject subclasses can now inherit from other CXX-Qt generated QObject classes
  • BUILD_WASM CMake option to support WebAssembly builds and a book page for building for WASM
  • Add support for cxx_name and rust_name on qproperty attributes which applies to the QProperty generated as well as functions

Changed

  • VCPKG is now being removed entirely
  • Connection now return a QMetaObjectConnectionGuard and QMetaObjectConnection is a separate type
  • Internal cxx-qt headers have moved to the namespace cxxqt1 and the folder cxx-qt
  • cxx-qt-gen now does not generate code requiring cxx-qt-lib, this allows for cxx-qt-lib to be optional
  • File name is used for CXX bridges rather than module name to match upstream
  • #[qobject] attribute is now optional on types in extern "RustQt"
  • #[qobject] attribute is now required on types in extern "C++Qt"
  • #[qenum]s now resolve their namespace independently from their associated QObject
  • Reworked cxx-qt-build and the integration with CMake
    • Dependencies are now automatically detected and configured by cxx-qt-build
    • Libraries can pass build information to cxx-qt-build in the form of a cxx_qt_build::Interface
    • Add CMake wrappers around corrosion to simplify importing crates and qml modules that were built with cxx-qt-build
    • CMake code has been extracted into a separate repository for faster downloads (kdab/cxx-qt-cmake)
  • Folder structure of Rust bridges is now considered in the same way as CXX in CxxQtBuilder
  • cxx_file_stem has been removed from #[cxx_qt::bridge] and the source file name is now used for generated headers similar to CXX
  • Base attribute now takes an ident not a string, e.g. #[base = ParentClass] instead of #[base = "ParentClass"]
  • No Cxx-qt-lib features are on by default now, instead we have a 'full' feature for the previously enabled features, making them opt in
  • Removed implicit auto camel conversion with no attributes, instead use cxx_name and rust_name like CXX (this may come back but be explicit opt-in)

Removed

  • qt_gui and qt_qml features from cxx-qt-build they are only used in cxx-qt-lib(-headers) now
  • cxx-qt-lib-headers and cxx-qt-lib-extras-headers are now merged into their respective base crates
  • BuildOpts are replaced by the Interface type which does not need to be reiterated by downstream dependencies
  • Locking has been removed from the generated QObjects. Qt/User C++ code is responsible for upholding Rusts Safety guarantees.
    • The cxx_qt::Locking trait is no longer available.

0.6.1

19 Apr 11:30

Choose a tag to compare

Fixed

  • Missing include for MaybeLockGuard when using only extern "C++Qt" signals
  • Fix build issues with Qt 6.7
  • Improve handling of Apple frameworks with Qt
  • Run qmlcachegen only when required
  • Support for building with no Rust or C++ files in the builder script

0.6.0

17 Nov 17:16

Choose a tag to compare

Added

  • Allow associated constants, types and macro invocations within impl qobject::T blocks
  • Ensure that generated Rust code works when #![deny(missing_docs)] is enabled
  • Ability to connect and disconnect from signals in Rust triggering a function pointer or closure
  • unsafe impl !cxx_qt::Locking for qobject::T to disable internal locking
  • Deref is now implemented for qobject::T to reach the T Rust struct
  • Support for C++ only methods by not having a #[qinvokable] attribute
  • Ability to define a custom C++ Constructor using cxx_qt::Constructor
  • cxx_qt::Initialize trait for easier default-constructor implementation
  • extern "C++Qt" block support for declaring existing types with methods and signals
  • #[qenum] attribute for Q_ENUM and Q_ENUM_NS support
  • qnamespace! macro to support exposing namespaced enums to QML

Changed

  • Pretty-print errors messages when build script fails
  • QDateTime API to use current_date_time rather than current_date
  • Always call qt_build_utils::setup_linker() in CxxQtBuilder and remove the proxy method
  • Moved to syn 2.0 internally and for any exported syn types
  • impl cxx_qt::Threading for qobject::T now needs to be specified for qt_thread() to be available
  • #[cxx_qt::qsignals] and #[cxx_qt::inherit] are now used in an extern "RustQt" block as #[qsignal] and #[inherit]
  • #[qinvokable] is now defined as a signature in extern "RustQt"
  • rust_mut is now safe to call
  • #[qproperty] is now defined as an attribute on the qobject rather than the field
  • QObject struct is now split between the bridge and implementation outside via a type alias
  • qobject module is no longer generated
  • impl cxx_qt::trait for qobject::T inside the bridge is now impl cxx_qt::trait for T
  • qobject::T as the self parameter in the bridge is now T
  • #[cxx_override], #[cxx_final], #[cxx_virtual] are now independant attributes rather than embedded in #[qinvokable]
  • Use set_organization_name instead of q{core,gui}application_set_organization_name in cxx-qt-lib

Fixed

  • Do not use -bundle otherwise CMake builds are missing qt-static-initalizers (note this is broken in rustc 1.69)
  • Do not import Pin in hidden module as invokables are outside now, resolving IDE integration
  • Rust always links against a non-debug Windows runtime with *-msvc targets, so we need to link to MultiThreadedDLL

Removed

  • Removed support for cxx_type and cxx_return_type and related conversion methods.
  • Removed newCppObject function that allowed creation of default-constructed QObject from Rust.
  • Generation of getter and setter for private Rust fields
  • Generation of mutable getter for properties, instead use rust_mut

0.5.3

19 May 12:54

Choose a tag to compare

Fixed

  • Ensure that QVariant{Hash,List,Map} cxx-qt-lib equivalents are registered so that they work in QML
  • Stop generating mut on self pins unnecessarily

0.5.2

27 Apr 19:17

Choose a tag to compare

Fixed

  • Builds failing due to link modifiers combination +bundle,+whole-archive is unstable when generating rlibs

0.5.1

27 Mar 14:29

Choose a tag to compare

Fixed

  • qrc resources added to CxxQtBuilder or QtBuild now trigger cargo:rerun-if-changed for file entries
  • Fix not being able to use QVariant as a #[qproperty], because the PartialEq implementation was missing