main.qml
import Qt 4.7
import "myscript.js" as MyScript
Rectangle {
id:main
MyScript.myFuction(); // This will execute fine, scope is fine
SecondQML {
}
}
import Qt 4.7
import "myscript.js" as MyScript
Rectangle {
id:main
MyScript.myFuction(); // This will execute fine, scope is fine
SecondQML {
}
}
To copy to clipboard, switch view to plain text mode
myscript.js
function myFuction() {
print('inside my function');
}
function myFuction() {
print('inside my function');
}
To copy to clipboard, switch view to plain text mode
SecondQML.qml
Rectangle {
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
MyScript.myFunction(); // Will not execute
}
}
}
Rectangle {
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
MyScript.myFunction(); // Will not execute
}
}
}
To copy to clipboard, switch view to plain text mode
I also tried main.MyScript.myFunction() it is out of scope. I need to be able to reference the same script instance from main.qml and not a newly initiated script from inside secondQML.qml
I can access main from here because of hierarchy but I am not sure why I cannot get to the MyScript property.
Bookmarks