[−][src]Crate qmetaobject
This crate implements binding to the Qt API.
Example:
extern crate qmetaobject; use qmetaobject::*; #[macro_use] extern crate cstr; #[derive(QObject,Default)] struct Greeter { base : qt_base_class!(trait QObject), name : qt_property!(QString; NOTIFY name_changed), name_changed : qt_signal!(), compute_greetings : qt_method!(fn compute_greetings(&self, verb : String) -> QString { return (verb + " " + &self.name.to_string()).into() }) } fn main() { qml_register_type::<Greeter>(cstr!("Greeter"), 1, 0, cstr!("Greeter")); let mut engine = QmlEngine::new(); engine.load_data(r#" import QtQuick 2.6; import QtQuick.Window 2.0; import Greeter 1.0 Window { visible: true; Greeter { id: greeter; name: 'World'; } Text { anchors.centerIn: parent; text: greeter.compute_greetings('hello'); } }"#.into()); engine.exec(); }
Re-exports
pub use qttypes::*; |
pub use itemmodel::*; |
pub use listmodel::*; |
pub use qtdeclarative::*; |
pub use qmetatype::*; |
pub use connections::RustSignal; |
pub use qtquickcontrols2::*; |
Modules
connections | |
itemmodel | |
listmodel | |
qmetatype | |
qrc | |
qtdeclarative | |
qtquickcontrols2 | |
qttypes | |
scenegraph |
Macros
qrc | Macro to embed files and made them available to the Qt resource system |
qt_base_class | This macro must be used once as a type in a struct that derives from QObject. It is anotate from which QObject like trait it is supposed to derive. the field which it annotate will be an internal property holding a pointer to the actual C++ object |
qt_method | This macro can be used to declare a method which will become a meta method. |
qt_plugin | Equivalent to the Q_PLUGIN_METADATA macro. |
qt_property | This macro can be used as a type of a field and can then turn this field in a Qt property. The first parameter is the type of this property. Then we can have the meta keywords similar to these found in Q_PROPERTY. |
qt_signal | Declares a signal |
Structs
QMessageLogContext | Wrapper for Qt's QMessageLogContext |
QObjectBox | A wrapper around RefCell |
QObjectPinned | A reference to a RefCell |
QObjectRefMut | Same as std::cell::RefMut, but does not allow to move from |
QPointer | A Wrapper around a QPointer |
Enums
QtMsgType | Wrap Qt's QtMsgType enum |
Constants
USER_ROLE | Refer to the documentation of Qt::UserRole |
Traits
QGadget | Trait that is implemented by the QGadget custom derive macro |
QObject | Trait that is implemented by the QObject custom derive macro |
Functions
install_message_handler | Wrap qt's qInstallMessageHandler. Useful in order to forward the log to a rust logging framework |
into_leaked_cpp_ptr | Create the C++ object and return a C++ pointer to a QObject. |
queued_callback | Create a callback to invoke a queued callback in the current thread. |
single_shot | Call the callback once, after a given duration. |