Attribute Macro qt_macros::ui_form[][src]

Expand description

Generates code for loading an UI file.


This attribute should be used on structs:

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.


  • 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.