Why not to make QML support loading over net?



  • 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:

    1. 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.
    2. support http/https
      • we can also support other custom transfer protocols via custom plugins
      • say, ssh
    3. 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
    4. support replacing unsupported Item or the one failed to load with a default empty one but not to crash or throw exception
    5. 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
    6. 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.



  • 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.



  • This post is deleted!


  • @Wieland thanks for your answer, and I'm sorry for posting before reading the doc throughout, I'll try the remote loading.



  • @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.



  • 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).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.