I have a javascript file (myfile.js) which declares :

var testVar = 0;

then I have a file main.qml:

import "myfile.js" as myfileJs;

page{
id :...;
main2{
id:testmain2;
}
button{
onClicked:{
myfileJs.testVar = 10;
console.debug(myfileJs.testVar); ///Gives 10 on console
pagestack.push(testmain2);
}
}
}

and another file, "main2.qml":

import "myfile.js" as myfileJs;

page{
id :...2;
button{
onClicked:{
console.debug(myfileJs.testVar); ///Gives 0 on console
}
}
}

Needless to say that in qmldir I declare main2 qml file.
Anyone experienced the same?