anothertest
13th April 2010, 10:46
Hello,
I've created a simple QML file which imports an external JavaScript file:
Test.qml
import Qt 4.6
import "a.js" as Misc
Rectangle {
width: 200
height: 500
Text {
text: Misc.doubleFloat(2.5)
anchors.right: parent.right
}
}
a.js
function doubleFloat(a) {
a = parseFloat(a);
return a*2;
}
Application Ouput panel shows
TypeError: Result of expression 'Misc.doubleFloat' [undefined] is not a function.
The function works fine if I inline it and remove the qualifier:
Test.qml
import Qt 4.6
Rectangle {
width: 200
height: 500
function doubleFloat(a) {
a = parseFloat(a);
return a*2;
}
Text {
text: doubleFloat(2.5)
anchors.right: parent.right
}
}
a.js is in the same directory as Test.qml, so there should be no problem locating it. I have also tried providing the absolute path in the import statement. I still receive the same error.
I'm using Qt 4.7 and QtCreator 2.0, both built from source on Windows XP
I've created a simple QML file which imports an external JavaScript file:
Test.qml
import Qt 4.6
import "a.js" as Misc
Rectangle {
width: 200
height: 500
Text {
text: Misc.doubleFloat(2.5)
anchors.right: parent.right
}
}
a.js
function doubleFloat(a) {
a = parseFloat(a);
return a*2;
}
Application Ouput panel shows
TypeError: Result of expression 'Misc.doubleFloat' [undefined] is not a function.
The function works fine if I inline it and remove the qualifier:
Test.qml
import Qt 4.6
Rectangle {
width: 200
height: 500
function doubleFloat(a) {
a = parseFloat(a);
return a*2;
}
Text {
text: doubleFloat(2.5)
anchors.right: parent.right
}
}
a.js is in the same directory as Test.qml, so there should be no problem locating it. I have also tried providing the absolute path in the import statement. I still receive the same error.
I'm using Qt 4.7 and QtCreator 2.0, both built from source on Windows XP