Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.7.4, 5.0.0
-
None
Description
QtQuick documentation (http://doc.qt.nokia.com/4.7/qdeclarativemodules.html#creating-installed-modules) says that a QML installed module located on the network is accessible as soon as its URL is properly added to the QML import path but it does not work. The QDeclarativeEngine API (http://doc.qt.nokia.com/4.7/qdeclarativeengine.html#addImportPath) also mentions that the "path" parameter in the "addImportPath(const QString& path)" method may be a local filesystem directory or a URL. However, if "path" is the string form of any valid QUrl object (i.e. scheme not empty), this path will never match any QML installed module. Only filesystem paths are currently working.
Here is the scenario I made to highlight the problem:
1) Create a simple QML element (MyRectangle.qml):
import QtQuick 1.0
Rectangle {
color: "red"
width: 200
height: 50
}
2) Create a "qmldir" file for the module containing the simple QML element above:
MyRectangle 1.0 MyRectangle.qml
3) Create another simple QML element (Test.qml) that uses the QML element above (MyRectangle.qml is supposed to come from a module whose URI is "com.company.module"):
import QtQuick 1.0
import com.company.module 1.0
Rectangle {
width: 400
height: 200
MyRectangle
{ x: 100; y: 80 }}
4) Create a correct directory structure for the QML module. For instance here is such a structure on my computer:
"C:/MyRoot/MyQmlModules/com/company/module"
5) Copy the "qmldir" and "MyRectangle.qml" files in the module directory above.
6) Copy the testing Qml element (Test.qml) in an unrelated directory like "C:/Temp".
7a) Publish the directory "C:/MyRoot" as the root of a local web server so that the "qmldir" file is available from the URL "http://localhost/MyQmlModules/com/company/module/qmldir".
7b) Run QmlViewer with the proper parameters:
qmlviewer.exe -I http://localhost/MyQmlModules C:/Temp/Test.qml
7c) The Warnings window of QmlViewer displays:
file:///C:/Temp/Test.qml:2:1: module "com.company.module" is not installed
import com.company.module 1.0
8a) Now, run QmlViewer with these parameters:
qmlviewer.exe -I C:/MyRoot/MyQmlModules C:/Temp/Test.qml
8b) No error, the red rectangle is properly displayed.
9a) Run QmlViewer with these parameters:
qmlviewer.exe -I file:///C:/MyRoot/MyQmlModules C:/Temp/Test.qml
9b) The Warnings window of QmlViewer displays:
file:///C:/Temp/Test.qml:2:1: module "com.company.module" is not installed
import com.company.module 1.0
As you can see, even for a path located on the local filesystem but expressed as a "file" URL, it does not work.
I have also checked with a "qrc" URL but QmlViewer failed in the same way. Actually, no import path formatted as a URL is working !