Trait qmetaobject::qmetatype::QMetaType
source · pub trait QMetaType: Clone + Default + 'static {
const CONVERSION_TO_STRING: Option<fn(_: &Self) -> QString> = None;
const CONVERSION_FROM_STRING: Option<fn(_: &QString) -> Self> = None;
// Provided methods
fn register(name: Option<&CStr>) -> i32 { ... }
fn id() -> i32 { ... }
fn to_qvariant(&self) -> QVariant { ... }
fn from_qvariant(variant: QVariant) -> Option<Self> { ... }
}
Expand description
Implement this trait for type that should be known to the QMetaObject system
Once implemented for a type, it can be used as a type of a qt_property! or as a parameter of a qt_method!
use qmetaobject::QMetaType;
#[derive(Default, Clone)]
struct MyStruct(u32, String);
impl QMetaType for MyStruct {}
Provided Associated Constants§
sourceconst CONVERSION_TO_STRING: Option<fn(_: &Self) -> QString> = None
const CONVERSION_TO_STRING: Option<fn(_: &Self) -> QString> = None
If this is set to a function, it enable the conversion to and from QString
const CONVERSION_FROM_STRING: Option<fn(_: &QString) -> Self> = None
Provided Methods§
sourcefn register(name: Option<&CStr>) -> i32
fn register(name: Option<&CStr>) -> i32
Registers the type.
See the Qt documentation of qRegisterMetaType()
The default implementation should work for most types
fn id() -> i32
sourcefn to_qvariant(&self) -> QVariant
fn to_qvariant(&self) -> QVariant
Returns a QVariant containing a copy of this object
sourcefn from_qvariant(variant: QVariant) -> Option<Self>
fn from_qvariant(variant: QVariant) -> Option<Self>
Attempt to convert from a QVariant to this type.
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
Implementors§
impl QMetaType for QJSValue
impl QMetaType for QByteArray
impl QMetaType for QColor
impl QMetaType for QDate
impl QMetaType for QDateTime
impl QMetaType for QImage
impl QMetaType for QJsonArray
impl QMetaType for QJsonObject
impl QMetaType for QJsonValue
impl QMetaType for QModelIndex
impl QMetaType for QPixmap
impl QMetaType for QPoint
impl QMetaType for QPointF
impl QMetaType for QRectF
impl QMetaType for QSize
impl QMetaType for QSizeF
impl QMetaType for QString
impl QMetaType for QStringList
impl QMetaType for QTime
impl QMetaType for QUrl
impl QMetaType for QVariant
impl QMetaType for QVariantList
impl QMetaType for QVariantMap
impl<T> QMetaType for T
QGadget are automatically QMetaType