How to get value from another qml
-
Hello everyone!
I have 2 qml files:
main.qmlthat containsStackViewand loader of another file:Loader { id: serportLoader active: false source: "serialport-view.qml" }On button pressing I push this file to stack:
serportLoader.active = true; stackView.push(serportLoader.item);The second qml looks like this:
ColumnLayout { SerialPortHandler { id: portHandler property bool isPortOpened: false ...So, can I somehow get a value of
isPortOpenedof theportHandlerobject?With
console.log(serportLoader.item.portHandler.isPortOpened);I getTypeError: Cannot read property 'isPortOpened' of undefined.I just want to get result of the work from the second qml file. Perhaps can you advise a better approach?
Thanks in advance! -
C Christian Ehrlicher moved this topic from General and Desktop on
-
Hello everyone!
I have 2 qml files:
main.qmlthat containsStackViewand loader of another file:Loader { id: serportLoader active: false source: "serialport-view.qml" }On button pressing I push this file to stack:
serportLoader.active = true; stackView.push(serportLoader.item);The second qml looks like this:
ColumnLayout { SerialPortHandler { id: portHandler property bool isPortOpened: false ...So, can I somehow get a value of
isPortOpenedof theportHandlerobject?With
console.log(serportLoader.item.portHandler.isPortOpened);I getTypeError: Cannot read property 'isPortOpened' of undefined.I just want to get result of the work from the second qml file. Perhaps can you advise a better approach?
Thanks in advance! -
@Atr0p0s I've never tried this with a loader, but you can put a signal in your serialport-view.qml file to return the value of isPortOpened. Maybe someone else can chime in on doing this through a loader...
-
@Atr0p0s I've never tried this with a loader, but you can put a signal in your serialport-view.qml file to return the value of isPortOpened. Maybe someone else can chime in on doing this through a loader...
-
A Atr0p0s has marked this topic as solved on