Skip to main content

QVariantConvertible

Trait QVariantConvertible 

Source
pub trait QVariantConvertible: Sized {
    // Required methods
    fn to_qvariant(&self) -> QVariant;
    fn try_from_qvariant(value: &QVariant) -> Result<Self, ()>;
}
Expand description

A type that cross to and from QML by value.

This is the bound for values stored in a model role (see QModelItem) and for value-typed properties and method arguments. Implemented for:

  • Primitive numeric types and bool
  • String
  • Vec<T> where T is one of the above

QObject handles (Rc<RefCell<T>>) are deliberately not QVariantConvertible as they cross as a pointer.

Required Methods§

Source

fn to_qvariant(&self) -> QVariant

Convert to QVariant. Intended for use with references only.

Source

fn try_from_qvariant(value: &QVariant) -> Result<Self, ()>

Fallible conversion from QVariant to a value type.

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 QVariantConvertible for Value

Available on crate feature serde_json only.
Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Value, ()>

Source§

impl QVariantConvertible for bool

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<bool, ()>

Source§

impl QVariantConvertible for f32

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<f32, ()>

Source§

impl QVariantConvertible for f64

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<f64, ()>

Source§

impl QVariantConvertible for i8

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<i8, ()>

Source§

impl QVariantConvertible for i16

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<i16, ()>

Source§

impl QVariantConvertible for i32

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<i32, ()>

Source§

impl QVariantConvertible for i64

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<i64, ()>

Source§

impl QVariantConvertible for isize

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<isize, ()>

Source§

impl QVariantConvertible for u8

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<u8, ()>

Source§

impl QVariantConvertible for u16

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<u16, ()>

Source§

impl QVariantConvertible for u32

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<u32, ()>

Source§

impl QVariantConvertible for u64

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<u64, ()>

Source§

impl QVariantConvertible for ()

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<(), ()>

Source§

impl QVariantConvertible for usize

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<usize, ()>

Source§

impl QVariantConvertible for String

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<String, ()>

Source§

impl QVariantConvertible for Vec<Value>

Available on crate feature serde_json only.
Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<Value>, ()>

Source§

impl QVariantConvertible for Vec<bool>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<bool>, ()>

Source§

impl QVariantConvertible for Vec<f32>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<f32>, ()>

Source§

impl QVariantConvertible for Vec<f64>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<f64>, ()>

Source§

impl QVariantConvertible for Vec<i8>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<i8>, ()>

Source§

impl QVariantConvertible for Vec<i16>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<i16>, ()>

Source§

impl QVariantConvertible for Vec<i32>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<i32>, ()>

Source§

impl QVariantConvertible for Vec<i64>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<i64>, ()>

Source§

impl QVariantConvertible for Vec<isize>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<isize>, ()>

Source§

impl QVariantConvertible for Vec<u8>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<u8>, ()>

Source§

impl QVariantConvertible for Vec<u16>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<u16>, ()>

Source§

impl QVariantConvertible for Vec<u32>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<u32>, ()>

Source§

impl QVariantConvertible for Vec<u64>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<u64>, ()>

Source§

impl QVariantConvertible for Vec<usize>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<usize>, ()>

Source§

impl QVariantConvertible for Vec<String>

Source§

fn to_qvariant(&self) -> QVariant

Source§

fn try_from_qvariant(value: &QVariant) -> Result<Vec<String>, ()>

Implementors§