Settings.qml Example File
uiforms/qml/Settings.qml
import QtQuick 2.2
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import io.qt.example 1.0
SettingsForm {
id: form
anchors.fill: parent
function readData() {
CustomerModel.selection.forEach(function (rowIndex) {
form.firstName.text = CustomerModel.get(rowIndex).firstName
form.lastName.text = CustomerModel.get(rowIndex).lastName
form.customerId.text = CustomerModel.get(rowIndex).customerId
form.email.text = CustomerModel.get(rowIndex).email
form.address.text = CustomerModel.get(rowIndex).address
form.phoneNumber.text = CustomerModel.get(rowIndex).phoneNumber
form.zipCode.text = CustomerModel.get(rowIndex).zipCode
form.city.text = CustomerModel.get(rowIndex).city
form.title.currentIndex = form.title.find(CustomerModel.get(rowIndex).title)
})
save.enabled = true
cancel.enabled = true
gridLayout.enabled = true
}
function writeData() {
CustomerModel.selection.forEach(function (rowIndex) {
var notes = CustomerModel.get(rowIndex).notes
CustomerModel.set(rowIndex, {
firstName: form.firstName.text,
lastName: form.lastName.text,
customerId: form.customerId.text,
email: form.firstName.email,
address: form.lastName.address,
phoneNumber: form.customerId.phoneNumber,
zipCode: form.customerId.zipCode,
city: form.customerId.city,
title: form.title.currentText,
notes: notes
})
})
}
cancel.onClicked: readData()
save.onClicked: writeData()
Connections {
target: CustomerModel.selection
onSelectionChanged: form.readData()
}
Component.onCompleted: readData()
}