I’m in the process of porting a QtQuick 1.x app to 2.0 and got hung up on a very odd spot:
ReferenceError: productsModel is not defined
The offending code is painfully simple:
import "binticketreport.js" as JS
Rectangle {
id: reportContainer
width: 400
height: 200
ListModel {
id: productsModel
}
Button {
onClicked: {
JS.binticketReport.scanSku();
}
}
}
and in the JS code:
Qt.include('otherscript.js');
var binticketReport = {
scanSku: function()
{
productsModel.append( { 'name': 'foo' } );
}
}
Google and the forums haven’t produced anything I could recognize as a solution.
I’ve discovered it stems from the use of Qt.include(”[removed]”); which appears to register within a blank rootContext.
Changing these occurances to use .import “[removed]” as <ReferenceName> fixes the issue.
I hope this helps others in their porting process.
↧