pub trait QPropertyMember: Sized {
// Required methods
fn qmetatype() -> QMetaType;
fn to_qvariant<Owner>(&self, owner: &Owner) -> QVariant
where Owner: QObjectHolder;
fn from_qvariant(value: &QVariant) -> Result<Self, ()>;
fn property_eq(&self, other: &Self) -> bool;
// Provided method
fn to_qvariant_view<Owner, Notify>(
&self,
owner: &Owner,
notify: Notify,
) -> QVariant
where Owner: QObjectHolder,
Notify: Fn(&mut Owner) + 'static { ... }
}Expand description
Enables a type to be used as a property.
Implemented for:
- Primitive numeric types and
bool StringVec<T>whereTis one of the aboveRc<RefCell<T>>whereTimplementsQObjectHolderVec<Rc<RefCell<T>>>whereTimplementsQmlRegister
You will not need to implement this trait yourself; adding support for custom types requires CXX/C++ bindings.
Required Methods§
fn qmetatype() -> QMetaType
Sourcefn to_qvariant<Owner>(&self, owner: &Owner) -> QVariantwhere
Owner: QObjectHolder,
fn to_qvariant<Owner>(&self, owner: &Owner) -> QVariantwhere
Owner: QObjectHolder,
Returns a QVariant representation of self for read operations.
Owner is the QObjectHolder that holds this property; passing it
allows returning views onto its members and borrowing correctly on
access. If the member is passed by value, owner can be ignored.
Sourcefn from_qvariant(value: &QVariant) -> Result<Self, ()>
fn from_qvariant(value: &QVariant) -> Result<Self, ()>
Converts value into the concrete type, used for write operations.
Sourcefn property_eq(&self, other: &Self) -> bool
fn property_eq(&self, other: &Self) -> bool
Returns true if self and other are equal.
Used to decide whether the notify signal should be emitted and the
stored value replaced on a property write.
Provided Methods§
Sourcefn to_qvariant_view<Owner, Notify>(
&self,
owner: &Owner,
notify: Notify,
) -> QVariant
fn to_qvariant_view<Owner, Notify>( &self, owner: &Owner, notify: Notify, ) -> QVariant
Returns a QVariant view of self for read operations, with access to
the property’s notify signal. Unlike to_qvariant,
this variant can return a live view that emits notify when the
underlying data changes.
The default implementation ignores notify and falls back to
to_qvariant.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl QPropertyMember for Value
Available on crate feature serde_json only.
impl QPropertyMember for Value
serde_json only.Source§impl QPropertyMember for bool
impl QPropertyMember for bool
Source§impl QPropertyMember for f32
impl QPropertyMember for f32
Source§impl QPropertyMember for f64
impl QPropertyMember for f64
Source§impl QPropertyMember for i8
impl QPropertyMember for i8
Source§impl QPropertyMember for i16
impl QPropertyMember for i16
Source§impl QPropertyMember for i32
impl QPropertyMember for i32
Source§impl QPropertyMember for i64
impl QPropertyMember for i64
Source§impl QPropertyMember for isize
impl QPropertyMember for isize
Source§impl QPropertyMember for u8
impl QPropertyMember for u8
Source§impl QPropertyMember for u16
impl QPropertyMember for u16
Source§impl QPropertyMember for u32
impl QPropertyMember for u32
Source§impl QPropertyMember for u64
impl QPropertyMember for u64
Source§impl QPropertyMember for usize
impl QPropertyMember for usize
Source§impl QPropertyMember for String
impl QPropertyMember for String
Source§impl QPropertyMember for Vec<Value>
Available on crate feature serde_json only.
impl QPropertyMember for Vec<Value>
serde_json only.