В слое QML есть TabView в нём есть Switch его id: control.
В id: control находится стояние вкл/выкл.
Как можно control передать в id: tab1 а именно в аргументы вызываемого метода backend.setProperties(control/передать сюда/); ?
TabView {
id: tabView
width: 300
height: 310
Tab {
id: tab
title: ""
Rectangle {
Switch {
id: control
x: 0
y: 0
width: 300
height: 50
text: qsTr("")
checked: false
onClicked: {
backend.setSwitch(control);
}
contentItem: Text {
rightPadding: control.indicator.width + control.spacing
text: control.text
font: control.font
opacity: enabled ? 1.0 : 0.3
color: control.down ? "#17a81a" : "#21be2b"
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
indicator: Rectangle {
implicitWidth: 48
implicitHeight: 26
x: control.width - width - control.rightPadding
y: parent.height / 2 - height / 2
radius: 13
color: control.checked ? "#17a81a" : "transparent"
border.color: control.checked ? "#17a81a" : "#cccccc"
Rectangle {
x: control.checked ? parent.width - width : 0
width: 26
height: 26
radius: 13
color: control.down ? "#cccccc" : "#ffffff"
border.color: control.checked ? (control.down ? "#17a81a" : "#21be2b") : "#999999"
}
}
background: Rectangle {
implicitWidth: 100
implicitHeight: 40
visible: control.down /*|| control.highlighted*/
color: control.down ? "#bdbebf" : "#eeeeee"
}
}
}
}
Tab {
id: tab1
source: "qml.qrc"
visible: true
title: ""
Rectangle {
Button {
id: button
x: 238
y: 150
width: 32
height: 32
onClicked: {
backend.setProperties(control/*передать сюда*/);
database.removeRecord();
database.inserIntoTable(textField.text, textField1.text);
}
}
}
}
}
}
control
Вы пробовали, и это не работает?property
у TabView и писать туда всё, что угодно. Так же в QML работают глобальные JS переменные (var global = "something";
)