Skip to content

Commit abe72d1

Browse files
authored
Implement PartialEq for QVariant (#490)
This fixes #[qproperty] not being available for QVariant, because the generated setter would use the equality operator. Fixes #487
1 parent b612f71 commit abe72d1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
### Fixed
2222

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

2526
## [0.5.0](https://github.com/KDAB/cxx-qt/compare/v0.4.1...v0.5.0) - 2023-03-08
2627

crates/cxx-qt-lib/src/core/qvariant/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ mod ffi {
3535
#[doc(hidden)]
3636
#[rust_name = "qvariant_clone"]
3737
fn construct(variant: &QVariant) -> QVariant;
38+
#[doc(hidden)]
39+
#[rust_name = "qvariant_eq"]
40+
fn operatorEq(a: &QVariant, b: &QVariant) -> bool;
3841
}
3942
}
4043

@@ -121,6 +124,12 @@ impl QVariant {
121124
}
122125
}
123126

127+
impl std::cmp::PartialEq for QVariant {
128+
fn eq(&self, other: &Self) -> bool {
129+
ffi::qvariant_eq(self, other)
130+
}
131+
}
132+
124133
pub trait QVariantValue {
125134
fn can_convert(variant: &QVariant) -> bool;
126135
fn construct(value: &Self) -> QVariant;

0 commit comments

Comments
 (0)