Function qmetaobject::queued_callback[][src]

pub fn queued_callback<T: Send, F: FnMut(T) + 'static>(
    func: F
) -> impl Fn(T) + Send + Sync + Clone
Expand description

Create a callback to invoke a queued callback in the current thread.

Returns a callback that can be called in any thread. Calling the callback will then call the given closure in the current Qt thread.

If the current thread does no longer have an event loop when the callback is sent, the callback will not be recieved.

use qmetaobject::queued_callback;

let callback = queued_callback(|()| println!("hello from main thread"));
std::thread::spawn(move || {callback(());}).join();