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§
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 Methods§
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)
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.