Hi All,

I'm trying to import a JavaScript file from a Remote Server in QML file as

import QtQuick 2.3
import QtQuick.Window 2.2
import "http://192.168.0.16/sample.js"; as Remote

Window {
    visible: true
    width: 360
    height: 360

    MouseArea {
        anchors.fill: parent
        onClicked: {
            console.log(Remote.myFunction())
        }
    }

    Text {
        objectName: "myText"
        text: qsTr("Hello World")
        anchors.centerIn: parent
    }
}

sample.js:

function myFunction() {
    var d = new Date();
    var n = d.toString();
    return n;
}

and main.cpp:

QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
qDebug() << engine.rootObjects().count();

So the problem here is engine.rootObjects().count() prints 0 in the above
scenario but the import succeeds as Remote.myFunction() properly prints the
date.

Now keeping everything the same and just commenting the import line
properly shows objects count as 1.
Also importing the javascript file locally also succeeds.
Is this a known issue ?

Environment:
Kubuntu 14.04, Qt 5.3.2
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to