[][src]Attribute Macro qt_ui_tools::ui_form

#[ui_form]

Generates code for loading an UI file.

Usage

This attribute should be used on structs:

This example is not tested
#[ui_form("../ui/form.ui")]
#[derive(Debug)]
struct Form {
    widget: QBox<QWidget>,
    add: QPtr<QPushButton>,
    //...
}

Specify path to the UI file as an argument of the attribute. The path must be relative to the current file. Content of the UI file will be embedded into the executable.

The macro will generate the function fn load() -> Self.

Requirements

  • The struct must contain named fields.
  • The first argument must have QBox<QWidget> type. This argument will contain the main widget.
  • Each of the following arguments must have a name corresponding to objectName of an object in the UI file. The type of the field must be QPtr<T>, where T must correspond to the type of the object.

The load() function will panic if the UI file is invalid or if a name or type of any field doesn't match the objects in the UI file.