TelamonForm
A form of Sections and TelamonFormEntry rows that knows when it is valid, shows every error with validate() and gives its entries the settings they save to.
Since 1.5.0
A TelamonForm holds Sections of TelamonFormEntry rows. It is a Qt Quick Layouts ColumnLayout, so anything else can sit beside the Sections (a button row, an InfoBanner). The form does not draw anything of its own: it collects its entries (they register when they are created and leave when they are destroyed) and answers for all of them. A page of a TelamonPreferencesDialog is a TelamonForm.
Example
TelamonForm {
id: form
settings: TelamonSettings { group: "Account" }
onAccepted: save()
Section {
title: qsTr("Account")
TelamonFormEntry {
label: qsTr("Name")
required: true
settingKey: "Name"
TelamonTextField { }
}
TelamonFormEntry {
label: qsTr("Email")
TelamonTextField { validator: TelamonEmailValidator { } }
}
}
PrimaryButton {
text: qsTr("Save")
enabled: form.valid
onClicked: save()
}
}Bind a primary button to enabled: form.valid, or leave it enabled and call form.validate() when it is clicked: validate() shows what is wrong and moves the focus there.
Properties
| Name | Type | Default | Description |
|---|---|---|---|
entries |
var (read-only) |
[] |
The entries inside, as an array, in reading order (their order in the item tree). |
settings |
TelamonSettings |
null |
Where the entries with a settingKey save. On a page of a TelamonPreferencesDialog the dialog's settings are used when the page has none. |
valid |
bool (read-only) |
— | True when every entry is valid. An entry that is disabled or hidden by the app counts as valid, and validate() never focuses it; one on a page that is not shown still counts. |
Signals
| Name | Description |
|---|---|
accepted() |
Return was pressed in a single-line field while the form is valid. When the form is not valid Return does what validate() does. |
Methods
| Signature | Description |
|---|---|
validate() |
Shows the error of every entry (not only those the user has left), moves the keyboard focus to the first invalid entry in reading order and returns valid. |
Accessibility
The form adds no accessible item. Each entry gives its control an accessible name (its label) and description (its help and error); see TelamonFormEntry.