I want to run js function like this
function setPersonalInfoValue(){ console.debug("setPersonalInfoValue()"); }
when the page loaded in QML.
I tried this:
Rectangle { id: page2 width: 100 height: 62 function setPersonalInfoValue(){ console.debug("setPersonalInfoValue()"); } }
I want to run setPersonalInfoValue() function when I switch between page 1 to page 2. How can I do this?
You need to load a TabContainers instance in your current QML and call the function tabClicked() on it for it to work. If your TabContainers instance is loaded in another QML file of your application you could also define a signal in one of their common ancestor and emit the signal in X.
JavaScript ExpressionsQML has a deep JavaScript integration, and allows signal handlers and methods to be defined in JavaScript. Another core feature of QML is the ability to specify and enforce relationships between object properties using property bindings, which are also defined using JavaScript.
Define the function in your root-node ( ApplicationWindow ). This will be the last place, QML will look for a name, before it resorts to the C++ -context properties. See here to find out, how the names of variables and functions are resolved in QML.
Finally, I used:
Component.onCompleted: { setPersonalInfoValue(); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With