QModelItem

Trait QModelItem 

Source
pub trait QModelItem {
Show 46 associated items type T0: QVariantConvertible; type T1: QVariantConvertible; type T2: QVariantConvertible; type T3: QVariantConvertible; type T4: QVariantConvertible; type T5: QVariantConvertible; type T6: QVariantConvertible; type T7: QVariantConvertible; type T8: QVariantConvertible; type T9: QVariantConvertible; type T10: QVariantConvertible; type T11: QVariantConvertible; type T12: QVariantConvertible; type T13: QVariantConvertible; type T14: QVariantConvertible; // Required method fn role_names() -> HashMap<i32, String>; // Provided methods fn get0(&self) -> Option<&Self::T0> { ... } fn get1(&self) -> Option<&Self::T1> { ... } fn get2(&self) -> Option<&Self::T2> { ... } fn get3(&self) -> Option<&Self::T3> { ... } fn get4(&self) -> Option<&Self::T4> { ... } fn get5(&self) -> Option<&Self::T5> { ... } fn get6(&self) -> Option<&Self::T6> { ... } fn get7(&self) -> Option<&Self::T7> { ... } fn get8(&self) -> Option<&Self::T8> { ... } fn get9(&self) -> Option<&Self::T9> { ... } fn get10(&self) -> Option<&Self::T10> { ... } fn get11(&self) -> Option<&Self::T11> { ... } fn get12(&self) -> Option<&Self::T12> { ... } fn get13(&self) -> Option<&Self::T13> { ... } fn get14(&self) -> Option<&Self::T14> { ... } fn set0(&mut self, _value: Self::T0) { ... } fn set1(&mut self, _value: Self::T1) { ... } fn set2(&mut self, _value: Self::T2) { ... } fn set3(&mut self, _value: Self::T3) { ... } fn set4(&mut self, _value: Self::T4) { ... } fn set5(&mut self, _value: Self::T5) { ... } fn set6(&mut self, _value: Self::T6) { ... } fn set7(&mut self, _value: Self::T7) { ... } fn set8(&mut self, _value: Self::T8) { ... } fn set9(&mut self, _value: Self::T9) { ... } fn set10(&mut self, _value: Self::T10) { ... } fn set11(&mut self, _value: Self::T11) { ... } fn set12(&mut self, _value: Self::T12) { ... } fn set13(&mut self, _value: Self::T13) { ... } fn set14(&mut self, _value: Self::T14) { ... }
}
Expand description

Trait representing a single item in a Qt item model.

This trait is implemented automatically by #[derive(QModelItem)] for structs and tuple structs and an implementation for primitive types and tuples is provided. It allows QtBridge to use the type in item models.

§Typical usage

Normally, you should not implement this manually. Use #[derive(QModelItem)] on your struct:

#[derive(QModelItem)]
struct Person {
    name: String,
    age: u32,
}

§Manual Implementation

If your struct contains fields that cannot be converted to QVariant, you need to implement QModelItem manually. Only include fields that are known to QtBridge in the getN and setN methods, and adjust role_names() accordingly.

Example:


use std::collections::HashMap;
use qtbridge::QModelItem;

struct CustomType {
    data: Vec<u8>, // cannot be directly converted to QVariant
    name: String,
}

impl QModelItem for CustomType {
    type T0 = String;
    type T1 = ();
    type T2 = ();
    type T3 = ();
    type T4 = ();
    type T5 = ();
    type T6 = ();
    type T7 = ();
    type T8 = ();
    type T9 = ();
    type T10 = ();
    type T11 = ();
    type T12 = ();
    type T13 = ();
    type T14 = ();

    fn get0(&self) -> Option<&String> {
        Some(&self.name)
    }

    fn set0(&mut self, value: String) {
        self.name = value;
    }

    fn role_names() -> HashMap<i32, String> {
        let roles = [(0x0, "name".into())];
        roles.into()
    }
}

Required Associated Types§

Source

type T0: QVariantConvertible

Source

type T1: QVariantConvertible

Source

type T2: QVariantConvertible

Source

type T3: QVariantConvertible

Source

type T4: QVariantConvertible

Source

type T5: QVariantConvertible

Source

type T6: QVariantConvertible

Source

type T7: QVariantConvertible

Source

type T8: QVariantConvertible

Source

type T9: QVariantConvertible

Source

type T10: QVariantConvertible

Source

type T11: QVariantConvertible

Source

type T12: QVariantConvertible

Source

type T13: QVariantConvertible

Source

type T14: QVariantConvertible

Required Methods§

Provided Methods§

Source

fn get0(&self) -> Option<&Self::T0>

Source

fn get1(&self) -> Option<&Self::T1>

Source

fn get2(&self) -> Option<&Self::T2>

Source

fn get3(&self) -> Option<&Self::T3>

Source

fn get4(&self) -> Option<&Self::T4>

Source

fn get5(&self) -> Option<&Self::T5>

Source

fn get6(&self) -> Option<&Self::T6>

Source

fn get7(&self) -> Option<&Self::T7>

Source

fn get8(&self) -> Option<&Self::T8>

Source

fn get9(&self) -> Option<&Self::T9>

Source

fn get10(&self) -> Option<&Self::T10>

Source

fn get11(&self) -> Option<&Self::T11>

Source

fn get12(&self) -> Option<&Self::T12>

Source

fn get13(&self) -> Option<&Self::T13>

Source

fn get14(&self) -> Option<&Self::T14>

Source

fn set0(&mut self, _value: Self::T0)

Source

fn set1(&mut self, _value: Self::T1)

Source

fn set2(&mut self, _value: Self::T2)

Source

fn set3(&mut self, _value: Self::T3)

Source

fn set4(&mut self, _value: Self::T4)

Source

fn set5(&mut self, _value: Self::T5)

Source

fn set6(&mut self, _value: Self::T6)

Source

fn set7(&mut self, _value: Self::T7)

Source

fn set8(&mut self, _value: Self::T8)

Source

fn set9(&mut self, _value: Self::T9)

Source

fn set10(&mut self, _value: Self::T10)

Source

fn set11(&mut self, _value: Self::T11)

Source

fn set12(&mut self, _value: Self::T12)

Source

fn set13(&mut self, _value: Self::T13)

Source

fn set14(&mut self, _value: Self::T14)

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 QModelItem for bool

Source§

type T0 = bool

Source§

type T1 = ()

Source§

type T2 = ()

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl QModelItem for f32

Source§

type T0 = f32

Source§

type T1 = ()

Source§

type T2 = ()

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl QModelItem for f64

Source§

type T0 = f64

Source§

type T1 = ()

Source§

type T2 = ()

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl QModelItem for i8

Source§

type T0 = i8

Source§

type T1 = ()

Source§

type T2 = ()

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl QModelItem for i16

Source§

type T0 = i16

Source§

type T1 = ()

Source§

type T2 = ()

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl QModelItem for i32

Source§

type T0 = i32

Source§

type T1 = ()

Source§

type T2 = ()

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl QModelItem for i64

Source§

type T0 = i64

Source§

type T1 = ()

Source§

type T2 = ()

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl QModelItem for u8

Source§

type T0 = u8

Source§

type T1 = ()

Source§

type T2 = ()

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl QModelItem for u16

Source§

type T0 = u16

Source§

type T1 = ()

Source§

type T2 = ()

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl QModelItem for u32

Source§

type T0 = u32

Source§

type T1 = ()

Source§

type T2 = ()

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl QModelItem for u64

Source§

type T0 = u64

Source§

type T1 = ()

Source§

type T2 = ()

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl QModelItem for String

Source§

type T0 = String

Source§

type T1 = ()

Source§

type T2 = ()

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl<T0, T1> QModelItem for (T0, T1)
where T0: QVariantConvertible, T1: QVariantConvertible,

Source§

type T0 = T0

Source§

type T1 = T1

Source§

type T2 = ()

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn get1(&self) -> Option<&Self::T1>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn set1(&mut self, value: Self::T1)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl<T0, T1, T2> QModelItem for (T0, T1, T2)
where T0: QVariantConvertible, T1: QVariantConvertible, T2: QVariantConvertible,

Source§

type T0 = T0

Source§

type T1 = T1

Source§

type T2 = T2

Source§

type T3 = ()

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn get1(&self) -> Option<&Self::T1>

Source§

fn get2(&self) -> Option<&Self::T2>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn set1(&mut self, value: Self::T1)

Source§

fn set2(&mut self, value: Self::T2)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl<T0, T1, T2, T3> QModelItem for (T0, T1, T2, T3)
where T0: QVariantConvertible, T1: QVariantConvertible, T2: QVariantConvertible, T3: QVariantConvertible,

Source§

type T0 = T0

Source§

type T1 = T1

Source§

type T2 = T2

Source§

type T3 = T3

Source§

type T4 = ()

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn get1(&self) -> Option<&Self::T1>

Source§

fn get2(&self) -> Option<&Self::T2>

Source§

fn get3(&self) -> Option<&Self::T3>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn set1(&mut self, value: Self::T1)

Source§

fn set2(&mut self, value: Self::T2)

Source§

fn set3(&mut self, value: Self::T3)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl<T0, T1, T2, T3, T4> QModelItem for (T0, T1, T2, T3, T4)
where T0: QVariantConvertible, T1: QVariantConvertible, T2: QVariantConvertible, T3: QVariantConvertible, T4: QVariantConvertible,

Source§

type T0 = T0

Source§

type T1 = T1

Source§

type T2 = T2

Source§

type T3 = T3

Source§

type T4 = T4

Source§

type T5 = ()

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn get1(&self) -> Option<&Self::T1>

Source§

fn get2(&self) -> Option<&Self::T2>

Source§

fn get3(&self) -> Option<&Self::T3>

Source§

fn get4(&self) -> Option<&Self::T4>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn set1(&mut self, value: Self::T1)

Source§

fn set2(&mut self, value: Self::T2)

Source§

fn set3(&mut self, value: Self::T3)

Source§

fn set4(&mut self, value: Self::T4)

Source§

fn role_names() -> HashMap<i32, String>

Source§

impl<T0, T1, T2, T3, T4, T5> QModelItem for (T0, T1, T2, T3, T4, T5)
where T0: QVariantConvertible, T1: QVariantConvertible, T2: QVariantConvertible, T3: QVariantConvertible, T4: QVariantConvertible, T5: QVariantConvertible,

Source§

type T0 = T0

Source§

type T1 = T1

Source§

type T2 = T2

Source§

type T3 = T3

Source§

type T4 = T4

Source§

type T5 = T5

Source§

type T6 = ()

Source§

type T7 = ()

Source§

type T8 = ()

Source§

type T9 = ()

Source§

type T10 = ()

Source§

type T11 = ()

Source§

type T12 = ()

Source§

type T13 = ()

Source§

type T14 = ()

Source§

fn get0(&self) -> Option<&Self::T0>

Source§

fn get1(&self) -> Option<&Self::T1>

Source§

fn get2(&self) -> Option<&Self::T2>

Source§

fn get3(&self) -> Option<&Self::T3>

Source§

fn get4(&self) -> Option<&Self::T4>

Source§

fn get5(&self) -> Option<&Self::T5>

Source§

fn set0(&mut self, value: Self::T0)

Source§

fn set1(&mut self, value: Self::T1)

Source§

fn set2(&mut self, value: Self::T2)

Source§

fn set3(&mut self, value: Self::T3)

Source§

fn set4(&mut self, value: Self::T4)

Source§

fn set5(&mut self, value: Self::T5)

Source§

fn role_names() -> HashMap<i32, String>

Implementors§