Skip to main content

qtbridge_type_lib/core/qmetaobject/
mod.rs

1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only
3
4#[cxx::bridge]
5mod ffi {
6    #[allow(clippy::missing_safety_doc)]
7    unsafe extern "C++" {
8        include!("qtbridge-type-lib/src/core/qmetaobject/cpp/qmetaobject.h");
9        /// The QMetaObject struct contains meta-information about Qt objects.
10        ///
11        /// See also: [QMetaObject documentation](https://doc.qt.io/qt-6/qmetaobject.html).
12        type QMetaObject;
13        include!("qtbridge-type-lib/src/core/qmetatype/cpp/qmetatype.h");
14        type QMetaType = crate::QMetaType;
15
16        /// Returns the metatype corresponding to this metaobject.
17        #[cxx_name = "metaType"]
18        fn meta_type(self: &QMetaObject) -> QMetaType;
19
20        #[cxx_name = "inherits"]
21        unsafe fn inherits_ptr(self: &QMetaObject, base: *const QMetaObject) -> bool;
22    }
23}
24
25pub use ffi::QMetaObject;
26
27impl QMetaObject {
28    /// Returns `true` if the class described by this QMetaObject
29    /// inherits the type described by `base`.
30    pub fn inherits(&self, base: &QMetaObject) -> bool {
31        unsafe { self.inherits_ptr(base) }
32    }
33}