Struct QmlEngine

Source
#[repr(C)]
pub struct QmlEngine { /* private fields */ }
Expand description

Wrap a Qt Application and a QmlEngine

Note that since there can only be one Application in the process, creating two QmlEngine at the same time is not allowed. Doing that will panic.

Implementations§

Source§

impl QmlEngine

Source

pub fn new() -> QmlEngine

Create a new QmlEngine

Source

pub fn load_file(&mut self, path: QString)

Loads a file as a qml file (See QQmlApplicationEngine::load(const QString & filePath))

Source

pub fn load_url(&mut self, url: QUrl)

Loads the root QML file located at url (See QQmlApplicationEngine::load(const QUrl &url))

Source

pub fn load_data(&mut self, data: QByteArray)

Loads qml data (See QQmlApplicationEngine::loadData)

Source

pub fn load_data_as(&mut self, data: QByteArray, url: QUrl)

Loads qml data with url as base url component (See QQmlApplicationEngine::loadData)

Source

pub fn exec(&self)

Launches the application

Source

pub fn quit(&self)

Closes the application

Source

pub fn set_property(&mut self, name: QString, value: QVariant)

Sets a property for this QML context (calls QQmlEngine::rootContext()->setContextProperty)

Source

pub fn set_object<T: QObject + Sized>(&mut self, obj: QObjectPinned<'_, T>)

Sets an object for this QML context (calls QQmlEngine::rootContext()->setContextObject)

Source

pub fn set_object_property<T: QObject + Sized>( &mut self, name: QString, obj: QObjectPinned<'_, T>, )

Sets a property for this QML context (calls QQmlEngine::rootContext()->setContextProperty)

Source

pub fn invoke_method(&mut self, name: QByteArray, args: &[QVariant]) -> QVariant

Source

pub fn invoke_method_noreturn(&mut self, name: QByteArray, args: &[QVariant])

This method is the same as [invoke_method] but does not capture or return function’s return value

Source

pub fn trim_component_cache(&self)

Source

pub fn clear_component_cache(&self)

Source

pub fn new_qobject<T: QObject>(&mut self, obj: T) -> QJSValue

Give a QObject to the engine by wrapping it in a QJSValue

This will create the C++ object. Panic if the C++ object was already created.

Source

pub fn add_import_path(&mut self, path: QString)

Adds an import path for this QML engine (calls QQmlEngine::addImportPath)

Source

pub fn cpp_ptr(&self) -> *mut c_void

Returns a pointer to the C++ object. The pointer is of the type QQmlEngine * in C++.

Trait Implementations§

Source§

impl Drop for QmlEngine

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.