Why not to make QML support loading over net?
-
wrote on 2 Dec 2017, 10:32 last edited by A Former User 12 Feb 2017, 14:37
The current world is over http, so why not to make QML support loading from a web server, so we can write web page in QML.
To approach this goal, I think we need to implement the following features:
- import qml/javascript over net with absolute/relative|local/remote URL
- say, with a qml import provider, etc.
- to recognize a relative URL over net, we need a session manager to keep the URL of current page
- it's better to support import a explicit qml file instead of the directory, or else we need to handle the case of multi directories import, which in the network situation will be high costly.
- support http/https
- we can also support other custom transfer protocols via custom plugins
- say, ssh
- support multiple QML versions
- check the compatibility of importing Modules, and give the needed QML library name if the checking fail
- support loading QML library from the given url, then we can download the needed libraries to local and give it to QML engine
- support replacing unsupported Item or the one failed to load with a default empty one but not to crash or throw exception
- to provide an item for link
- or we need to implement this item in a qml file and find a way to tell the root qml reload whole page
- a page cache/persistent module is also needed
I think we need to implement these features in the QML engine to meet the basic requirement of loading QML over net.
- import qml/javascript over net with absolute/relative|local/remote URL
-
wrote on 2 Dec 2017, 23:23 last edited by
You can already implement that on top of the current engine. On the other hand, there is already a global standard for that usecase, with various implementations across all platforms: html et al.
-
wrote on 3 Dec 2017, 04:58 last edited byThis post is deleted!
-
You can already implement that on top of the current engine. On the other hand, there is already a global standard for that usecase, with various implementations across all platforms: html et al.
wrote on 3 Dec 2017, 05:07 last edited by@Wieland thanks for your answer, and I'm sorry for posting before reading the doc throughout, I'll try the remote loading.
-
You can already implement that on top of the current engine. On the other hand, there is already a global standard for that usecase, with various implementations across all platforms: html et al.
wrote on 3 Dec 2017, 05:50 last edited by@Wieland I tried to load a qml file with a single Rectangle via http with qmlscene and it works
import QtQuick 2.0 import QtQuick.Controls 1.4 ApplicationWindow { id: window visible: true width: 640 height: 480 Rectangle { id: container anchors.fill: parent color: "blue" } }
However, when I add a relative import, it works for local loading, but not work for remote loading:
# hello_world.qml import QtQuick 2.0 import QtQuick.Controls 1.4 import "sub" ApplicationWindow { id: window visible: true width: 640 height: 480 Rectangle { id: container anchors.fill: parent color: "blue" Sub { id: sub anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top height: parent.height / 2 } } }
#sub/Sub.qml import QtQuick 2.0 import QtQuick.Controls 1.4 Rectangle { }
I load the qml with command:
qmlscene "http://localhost/qml/hello_world.qml"
it throws the error: "http://localhost/qml/hello_world.qml:17 Sub is not a type"
I think this means that, though QQmlApplicationEngine support loading a remote url, but it doesn't work correctly in importing case. I think maybe it keep the incorrect url for sub directory or it want to import all files under the remote url, which is impossible. I haven't read the QQmlApplicationEngine code and can't make conclusion, but obviously, the current QQmlApplicationEngine can't be used in real work of remote deploying.
-
wrote on 3 Dec 2017, 12:43 last edited by
You can submit a suggestion at bugreports.qt.io to make sure that the framework developers take notice of it (this forum is more for users).
1/6