#[ui_form]
Expand description
Generates code for loading an UI file.
§Usage
This attribute should be used on structs:
ⓘ
#[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 beQPtr<T>
, whereT
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.