[Interest] QQmlApplicationEngine's rootObject() returns 0 objects count when trying to import of JavaScript file from Remote Server
Alejandro Exojo
suy at badopi.org
Fri Nov 14 15:18:04 CET 2014
El Friday 14 November 2014, ashish dabhade escribió:
> No need to click even. It happens during load. Loading locally works as
> expected. The JS file is proper. Just a single function in it
I have to admit my ignorance respect network transparency with Qt Quick, but
I've searched a bit and I've found:
- QML files are network transparent, but you load a directory, and on the
server you need the corresponding "qmldir" file to have the proper file loaded.
- JS should be network transparent as well, but the only examples I've found
make use of a remote QML file that loads a relative JS file (that then resolves
to the network).
- I've found no examples or tests in the qtdeclarative repository that import
a JS file from the network like in your example.
*However*, I tried runing the example with "qml" instead of "qmlscene" and it
works fine.
$ cat /var/www/sample.js
.pragma library
function myFunction() {
var d = new Date();
return d.toString();
}
$ cat test.qml
import QtQuick 2.3
import "http://localhost/sample.js" as Remote
Rectangle {
width: 360
height: 360
MouseArea {
anchors.fill: parent
onClicked: {
console.log(Remote.myFunction());
}
}
Text {
anchors.centerIn: parent
text: "Hello World"
}
}
The "qml" program (a.k.a. "QML runtime") is something that I really can't
explain properly, and is very hard to search for in the docs. Here is a talk
by Alan Alpert introducing it:
https://www.youtube.com/watch?v=2nnrl1v7LcE
Hopefully someone with more knowledge can explain the issue.
--
Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2
http://barnacity.net/ | http://disperso.net
More information about the Interest
mailing list