Skip to main content

invoke_method

Macro invoke_method 

Source
macro_rules! invoke_method {
    ($invoker:expr, $name:expr $(,)?) => { ... };
    ($invoker:expr, $name:expr, $($arg:expr),+ $(,)?) => { ... };
}
Expand description

Invokes a slot or signal by name on a QmlMethodInvoker.

Without extra arguments, delegates to QmlMethodInvoker::invoke_method. With extra arguments, constructs the argument list and delegates to QmlMethodInvoker::invoke_method_with_args.

use qtbridge::invoke_method;
use qtbridge::{qobject, QObjectHolder};

#[derive(Default)]
pub struct MyClass { }

#[qobject]
impl MyClass {
    #[qslot]
    fn set_value(&mut self, value: i32) { }

    #[qslot]
    fn reset(&self) { }
}

let obj = MyClass::default_with_attached_qobject();
let invoker = obj.borrow().get_qml_method_invoker();
invoke_method!(invoker, "reset");
invoke_method!(invoker, "setValue", 42);