[][src]Struct qt_ui_tools::QUiLoader

#[repr(C)]pub struct QUiLoader { /* fields omitted */ }

The QUiLoader class enables standalone applications to dynamically create user interfaces at run-time using the information stored in UI files or specified in plugin paths.

C++ class: QUiLoader.

C++ documentation:

The QUiLoader class enables standalone applications to dynamically create user interfaces at run-time using the information stored in UI files or specified in plugin paths.

In addition, you can customize or create your own user interface by deriving your own loader class.

If you have a custom component or an application that embeds Qt Designer, you can also use the QFormBuilder class provided by the QtDesigner module to create user interfaces from UI files.

The QUiLoader class provides a collection of functions allowing you to create widgets based on the information stored in UI files (created with Qt Designer) or available in the specified plugin paths. The specified plugin paths can be retrieved using the pluginPaths() function. Similarly, the contents of a UI file can be retrieved using the load() function. For example:

MyWidget::MyWidget(QWidget parent) : QWidget(parent) { QUiLoader loader; QFile file(":/forms/myform.ui"); file.open(QFile::ReadOnly); QWidget myWidget = loader.load(&file, this); file.close();

QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(myWidget); setLayout(layout); }

By including the user interface in the form's resources (myform.qrc), we ensure that it will be present at run-time:

<!DOCTYPE RCC><RCC version="1.0"> <qresource prefix="/forms"> <file>myform.ui</file> </qresource> </RCC>

The availableWidgets() function returns a QStringList with the class names of the widgets available in the specified plugin paths. To create these widgets, simply use the createWidget() function. For example:

QWidget loadCustomWidget(QWidget parent) { QUiLoader loader; QWidget *myWidget;

QStringList availableWidgets = loader.availableWidgets();

if (availableWidgets.contains("AnalogClock")) myWidget = loader.createWidget("AnalogClock", parent);

return myWidget; }

To make a custom widget available to the loader, you can use the addPluginPath() function; to remove all available widgets, you can call the clearPluginPaths() function.

The createAction(), createActionGroup(), createLayout(), and createWidget() functions are used internally by the QUiLoader class whenever it has to create an action, action group, layout, or widget respectively. For that reason, you can subclass the QUiLoader class and reimplement these functions to intervene the process of constructing a user interface. For example, you might want to have a list of the actions created when loading a form or creating a custom widget.

For a complete example using the QUiLoader class, see the Calculator Builder Example.

Methods

impl QUiLoader[src]

pub unsafe fn load_bytes(&self, bytes: &[u8]) -> QBox<QWidget>[src]

Loads a form from the given UI file data and creates a new widget to hold its contents.

pub unsafe fn load_bytes_with_parent(
    &self,
    bytes: &[u8],
    parent: impl CastInto<Ptr<QWidget>>
) -> QBox<QWidget>
[src]

Loads a form from the given UI file data and creates a new widget with the given parent to hold its contents.

impl QUiLoader[src]

pub unsafe fn add_plugin_path(&self, path: impl CastInto<Ref<QString>>)[src]

Adds the given path to the list of paths in which the loader will search when locating plugins.

Calls C++ function: void QUiLoader::addPluginPath(const QString& path).

C++ documentation:

Adds the given path to the list of paths in which the loader will search when locating plugins.

See also pluginPaths() and clearPluginPaths().

pub unsafe fn available_layouts(&self) -> CppBox<QStringList>[src]

Returns a list naming all available layouts that can be built using the createLayout() function

Calls C++ function: QStringList QUiLoader::availableLayouts() const.

C++ documentation:

Returns a list naming all available layouts that can be built using the createLayout() function

This function was introduced in Qt 4.5.

See also createLayout().

pub unsafe fn available_widgets(&self) -> CppBox<QStringList>[src]

Returns a list naming all available widgets that can be built using the createWidget() function, i.e all the widgets specified within the given plugin paths.

Calls C++ function: QStringList QUiLoader::availableWidgets() const.

C++ documentation:

Returns a list naming all available widgets that can be built using the createWidget() function, i.e all the widgets specified within the given plugin paths.

See also pluginPaths() and createWidget().

pub unsafe fn clear_plugin_paths(&self)[src]

Clears the list of paths in which the loader will search when locating plugins.

Calls C++ function: void QUiLoader::clearPluginPaths().

C++ documentation:

Clears the list of paths in which the loader will search when locating plugins.

See also addPluginPath() and pluginPaths().

pub unsafe fn create_action_2a(
    &self,
    parent: impl CastInto<Ptr<QObject>>,
    name: impl CastInto<Ref<QString>>
) -> QPtr<QAction>
[src]

Creates a new action with the given parent and name.

Calls C++ function: virtual QAction* QUiLoader::createAction(QObject* parent = …, const QString& name = …).

C++ documentation:

Creates a new action with the given parent and name.

The function is also used internally by the QUiLoader class whenever it creates a widget. Hence, you can subclass QUiLoader and reimplement this function to intervene process of constructing a user interface or widget. However, in your implementation, ensure that you call QUiLoader's version first.

See also createActionGroup(), createWidget(), and load().

pub unsafe fn create_action_1a(
    &self,
    parent: impl CastInto<Ptr<QObject>>
) -> QPtr<QAction>
[src]

Creates a new action with the given parent and name.

Calls C++ function: virtual QAction* QUiLoader::createAction(QObject* parent = …).

C++ documentation:

Creates a new action with the given parent and name.

The function is also used internally by the QUiLoader class whenever it creates a widget. Hence, you can subclass QUiLoader and reimplement this function to intervene process of constructing a user interface or widget. However, in your implementation, ensure that you call QUiLoader's version first.

See also createActionGroup(), createWidget(), and load().

pub unsafe fn create_action_0a(&self) -> QPtr<QAction>[src]

Creates a new action with the given parent and name.

Calls C++ function: virtual QAction* QUiLoader::createAction().

C++ documentation:

Creates a new action with the given parent and name.

The function is also used internally by the QUiLoader class whenever it creates a widget. Hence, you can subclass QUiLoader and reimplement this function to intervene process of constructing a user interface or widget. However, in your implementation, ensure that you call QUiLoader's version first.

See also createActionGroup(), createWidget(), and load().

pub unsafe fn create_action_group_2a(
    &self,
    parent: impl CastInto<Ptr<QObject>>,
    name: impl CastInto<Ref<QString>>
) -> QPtr<QActionGroup>
[src]

Creates a new action group with the given parent and name.

Calls C++ function: virtual QActionGroup* QUiLoader::createActionGroup(QObject* parent = …, const QString& name = …).

C++ documentation:

Creates a new action group with the given parent and name.

The function is also used internally by the QUiLoader class whenever it creates a widget. Hence, you can subclass QUiLoader and reimplement this function to intervene process of constructing a user interface or widget. However, in your implementation, ensure that you call QUiLoader's version first.

See also createAction(), createWidget(), and load().

pub unsafe fn create_action_group_1a(
    &self,
    parent: impl CastInto<Ptr<QObject>>
) -> QPtr<QActionGroup>
[src]

Creates a new action group with the given parent and name.

Calls C++ function: virtual QActionGroup* QUiLoader::createActionGroup(QObject* parent = …).

C++ documentation:

Creates a new action group with the given parent and name.

The function is also used internally by the QUiLoader class whenever it creates a widget. Hence, you can subclass QUiLoader and reimplement this function to intervene process of constructing a user interface or widget. However, in your implementation, ensure that you call QUiLoader's version first.

See also createAction(), createWidget(), and load().

pub unsafe fn create_action_group_0a(&self) -> QPtr<QActionGroup>[src]

Creates a new action group with the given parent and name.

Calls C++ function: virtual QActionGroup* QUiLoader::createActionGroup().

C++ documentation:

Creates a new action group with the given parent and name.

The function is also used internally by the QUiLoader class whenever it creates a widget. Hence, you can subclass QUiLoader and reimplement this function to intervene process of constructing a user interface or widget. However, in your implementation, ensure that you call QUiLoader's version first.

See also createAction(), createWidget(), and load().

pub unsafe fn create_layout_3a(
    &self,
    class_name: impl CastInto<Ref<QString>>,
    parent: impl CastInto<Ptr<QObject>>,
    name: impl CastInto<Ref<QString>>
) -> QPtr<QLayout>
[src]

Creates a new layout with the given parent and name using the class specified by className.

Calls C++ function: virtual QLayout* QUiLoader::createLayout(const QString& className, QObject* parent = …, const QString& name = …).

C++ documentation:

Creates a new layout with the given parent and name using the class specified by className.

The function is also used internally by the QUiLoader class whenever it creates a widget. Hence, you can subclass QUiLoader and reimplement this function to intervene process of constructing a user interface or widget. However, in your implementation, ensure that you call QUiLoader's version first.

See also createWidget() and load().

pub unsafe fn create_layout_2a(
    &self,
    class_name: impl CastInto<Ref<QString>>,
    parent: impl CastInto<Ptr<QObject>>
) -> QPtr<QLayout>
[src]

Creates a new layout with the given parent and name using the class specified by className.

Calls C++ function: virtual QLayout* QUiLoader::createLayout(const QString& className, QObject* parent = …).

C++ documentation:

Creates a new layout with the given parent and name using the class specified by className.

The function is also used internally by the QUiLoader class whenever it creates a widget. Hence, you can subclass QUiLoader and reimplement this function to intervene process of constructing a user interface or widget. However, in your implementation, ensure that you call QUiLoader's version first.

See also createWidget() and load().

pub unsafe fn create_layout_1a(
    &self,
    class_name: impl CastInto<Ref<QString>>
) -> QPtr<QLayout>
[src]

Creates a new layout with the given parent and name using the class specified by className.

Calls C++ function: virtual QLayout* QUiLoader::createLayout(const QString& className).

C++ documentation:

Creates a new layout with the given parent and name using the class specified by className.

The function is also used internally by the QUiLoader class whenever it creates a widget. Hence, you can subclass QUiLoader and reimplement this function to intervene process of constructing a user interface or widget. However, in your implementation, ensure that you call QUiLoader's version first.

See also createWidget() and load().

pub unsafe fn create_widget_3a(
    &self,
    class_name: impl CastInto<Ref<QString>>,
    parent: impl CastInto<Ptr<QWidget>>,
    name: impl CastInto<Ref<QString>>
) -> QPtr<QWidget>
[src]

Creates a new widget with the given parent and name using the class specified by className. You can use this function to create any of the widgets returned by the availableWidgets() function.

Calls C++ function: virtual QWidget* QUiLoader::createWidget(const QString& className, QWidget* parent = …, const QString& name = …).

C++ documentation:

Creates a new widget with the given parent and name using the class specified by className. You can use this function to create any of the widgets returned by the availableWidgets() function.

The function is also used internally by the QUiLoader class whenever it creates a widget. Hence, you can subclass QUiLoader and reimplement this function to intervene process of constructing a user interface or widget. However, in your implementation, ensure that you call QUiLoader's version first.

See also availableWidgets() and load().

pub unsafe fn create_widget_2a(
    &self,
    class_name: impl CastInto<Ref<QString>>,
    parent: impl CastInto<Ptr<QWidget>>
) -> QPtr<QWidget>
[src]

Creates a new widget with the given parent and name using the class specified by className. You can use this function to create any of the widgets returned by the availableWidgets() function.

Calls C++ function: virtual QWidget* QUiLoader::createWidget(const QString& className, QWidget* parent = …).

C++ documentation:

Creates a new widget with the given parent and name using the class specified by className. You can use this function to create any of the widgets returned by the availableWidgets() function.

The function is also used internally by the QUiLoader class whenever it creates a widget. Hence, you can subclass QUiLoader and reimplement this function to intervene process of constructing a user interface or widget. However, in your implementation, ensure that you call QUiLoader's version first.

See also availableWidgets() and load().

pub unsafe fn create_widget_1a(
    &self,
    class_name: impl CastInto<Ref<QString>>
) -> QPtr<QWidget>
[src]

Creates a new widget with the given parent and name using the class specified by className. You can use this function to create any of the widgets returned by the availableWidgets() function.

Calls C++ function: virtual QWidget* QUiLoader::createWidget(const QString& className).

C++ documentation:

Creates a new widget with the given parent and name using the class specified by className. You can use this function to create any of the widgets returned by the availableWidgets() function.

The function is also used internally by the QUiLoader class whenever it creates a widget. Hence, you can subclass QUiLoader and reimplement this function to intervene process of constructing a user interface or widget. However, in your implementation, ensure that you call QUiLoader's version first.

See also availableWidgets() and load().

pub unsafe fn error_string(&self) -> CppBox<QString>[src]

Returns a human-readable description of the last error occurred in load().

Calls C++ function: QString QUiLoader::errorString() const.

C++ documentation:

Returns a human-readable description of the last error occurred in load().

This function was introduced in Qt 5.0.

See also load().

pub unsafe fn is_language_change_enabled(&self) -> bool[src]

Returns true if dynamic retranslation on language change is enabled; returns false otherwise.

Calls C++ function: bool QUiLoader::isLanguageChangeEnabled() const.

C++ documentation:

Returns true if dynamic retranslation on language change is enabled; returns false otherwise.

This function was introduced in Qt 4.5.

See also setLanguageChangeEnabled().

pub unsafe fn is_translation_enabled(&self) -> bool[src]

Calls C++ function: bool QUiLoader::isTranslationEnabled() const.

pub unsafe fn load_2a(
    &self,
    device: impl CastInto<Ptr<QIODevice>>,
    parent_widget: impl CastInto<Ptr<QWidget>>
) -> QPtr<QWidget>
[src]

Loads a form from the given device and creates a new widget with the given parentWidget to hold its contents.

Calls C++ function: QWidget* QUiLoader::load(QIODevice* device, QWidget* parentWidget = …).

C++ documentation:

Loads a form from the given device and creates a new widget with the given parentWidget to hold its contents.

See also createWidget() and errorString().

pub unsafe fn load_1a(
    &self,
    device: impl CastInto<Ptr<QIODevice>>
) -> QPtr<QWidget>
[src]

Loads a form from the given device and creates a new widget with the given parentWidget to hold its contents.

Calls C++ function: QWidget* QUiLoader::load(QIODevice* device).

C++ documentation:

Loads a form from the given device and creates a new widget with the given parentWidget to hold its contents.

See also createWidget() and errorString().

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QUiLoader::metaObject() const.

pub unsafe fn new_1a(parent: impl CastInto<Ptr<QObject>>) -> QBox<QUiLoader>[src]

Creates a form loader with the given parent.

Calls C++ function: [constructor] void QUiLoader::QUiLoader(QObject* parent = …).

C++ documentation:

Creates a form loader with the given parent.

pub unsafe fn new_0a() -> QBox<QUiLoader>[src]

The QUiLoader class enables standalone applications to dynamically create user interfaces at run-time using the information stored in UI files or specified in plugin paths.

Calls C++ function: [constructor] void QUiLoader::QUiLoader().

C++ documentation:

The QUiLoader class enables standalone applications to dynamically create user interfaces at run-time using the information stored in UI files or specified in plugin paths.

In addition, you can customize or create your own user interface by deriving your own loader class.

If you have a custom component or an application that embeds Qt Designer, you can also use the QFormBuilder class provided by the QtDesigner module to create user interfaces from UI files.

The QUiLoader class provides a collection of functions allowing you to create widgets based on the information stored in UI files (created with Qt Designer) or available in the specified plugin paths. The specified plugin paths can be retrieved using the pluginPaths() function. Similarly, the contents of a UI file can be retrieved using the load() function. For example:

MyWidget::MyWidget(QWidget parent) : QWidget(parent) { QUiLoader loader; QFile file(":/forms/myform.ui"); file.open(QFile::ReadOnly); QWidget myWidget = loader.load(&file, this); file.close();

QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(myWidget); setLayout(layout); }

By including the user interface in the form's resources (myform.qrc), we ensure that it will be present at run-time:

<!DOCTYPE RCC><RCC version="1.0"> <qresource prefix="/forms"> <file>myform.ui</file> </qresource> </RCC>

The availableWidgets() function returns a QStringList with the class names of the widgets available in the specified plugin paths. To create these widgets, simply use the createWidget() function. For example:

QWidget loadCustomWidget(QWidget parent) { QUiLoader loader; QWidget *myWidget;

QStringList availableWidgets = loader.availableWidgets();

if (availableWidgets.contains("AnalogClock")) myWidget = loader.createWidget("AnalogClock", parent);

return myWidget; }

To make a custom widget available to the loader, you can use the addPluginPath() function; to remove all available widgets, you can call the clearPluginPaths() function.

The createAction(), createActionGroup(), createLayout(), and createWidget() functions are used internally by the QUiLoader class whenever it has to create an action, action group, layout, or widget respectively. For that reason, you can subclass the QUiLoader class and reimplement these functions to intervene the process of constructing a user interface. For example, you might want to have a list of the actions created when loading a form or creating a custom widget.

For a complete example using the QUiLoader class, see the Calculator Builder Example.

pub unsafe fn plugin_paths(&self) -> CppBox<QStringList>[src]

Returns a list naming the paths in which the loader will search when locating custom widget plugins.

Calls C++ function: QStringList QUiLoader::pluginPaths() const.

C++ documentation:

Returns a list naming the paths in which the loader will search when locating custom widget plugins.

See also addPluginPath() and clearPluginPaths().

pub unsafe fn qt_metacall(
    &self,
    arg1: Call,
    arg2: c_int,
    arg3: *mut *mut c_void
) -> c_int
[src]

Calls C++ function: virtual int QUiLoader::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void[src]

Calls C++ function: virtual void* QUiLoader::qt_metacast(const char* arg1).

pub unsafe fn set_language_change_enabled(&self, enabled: bool)[src]

If enabled is true, user interfaces loaded by this loader will automatically retranslate themselves upon receiving a language change event. Otherwise, the user interfaces will not be retranslated.

Calls C++ function: void QUiLoader::setLanguageChangeEnabled(bool enabled).

C++ documentation:

If enabled is true, user interfaces loaded by this loader will automatically retranslate themselves upon receiving a language change event. Otherwise, the user interfaces will not be retranslated.

This function was introduced in Qt 4.5.

See also isLanguageChangeEnabled().

pub unsafe fn set_translation_enabled(&self, enabled: bool)[src]

Calls C++ function: void QUiLoader::setTranslationEnabled(bool enabled).

pub unsafe fn set_working_directory(&self, dir: impl CastInto<Ref<QDir>>)[src]

Sets the working directory of the loader to dir. The loader will look for other resources, such as icons and resource files, in paths relative to this directory.

Calls C++ function: void QUiLoader::setWorkingDirectory(const QDir& dir).

C++ documentation:

Sets the working directory of the loader to dir. The loader will look for other resources, such as icons and resource files, in paths relative to this directory.

See also workingDirectory().

pub unsafe fn static_meta_object() -> Ref<QMetaObject>[src]

Returns a reference to the staticMetaObject field.

pub unsafe fn tr(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QUiLoader::tr(const char* s, const char* c, int n).

pub unsafe fn tr_utf8(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QUiLoader::trUtf8(const char* s, const char* c, int n).

pub unsafe fn working_directory(&self) -> CppBox<QDir>[src]

Returns the working directory of the loader.

Calls C++ function: QDir QUiLoader::workingDirectory() const.

C++ documentation:

Returns the working directory of the loader.

See also setWorkingDirectory().

Trait Implementations

impl CppDeletable for QUiLoader[src]

unsafe fn delete(&self)[src]

Destroys the loader.

Calls C++ function: virtual [destructor] void QUiLoader::~QUiLoader().

C++ documentation:

Destroys the loader.

impl Deref for QUiLoader[src]

type Target = QObject

The resulting type after dereferencing.

fn deref(&self) -> &QObject[src]

Calls C++ function: QObject* static_cast<QObject*>(QUiLoader* ptr).

impl DynamicCast<QUiLoader> for QObject[src]

unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QUiLoader>[src]

Calls C++ function: QUiLoader* dynamic_cast<QUiLoader*>(QObject* ptr).

impl StaticDowncast<QUiLoader> for QObject[src]

unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QUiLoader>[src]

Calls C++ function: QUiLoader* static_cast<QUiLoader*>(QObject* ptr).

impl StaticUpcast<QObject> for QUiLoader[src]

unsafe fn static_upcast(ptr: Ptr<QUiLoader>) -> Ptr<QObject>[src]

Calls C++ function: QObject* static_cast<QObject*>(QUiLoader* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.