Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › serving QML over network

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #14491

    Bas

    hi,

    i just wanted to hear your opinion about serving QML Apps over the network?

    here is a url about it:

    http://www.slideshare.net/jeremylaine/serving-qml-applications-over-the-network

    I made a sample app which can do this, but it needs a QML starting point as of the v-play engine does not understand:

    vplay.setMainQmlFileName(QUrl(“http://domain.net/qmltest/Main.qml”));

    so i would like to hear from v-play about this aproach.

     

    thanx in advance, bas

    #14492

    Alex
    Felgo Team

    Hi Bas,

    while this might not work with setting the root component to a remote one at the moment, you can use a Loader to load your qml files remotely.

    E.g. you can try this code in your Main.qml:

    import Felgo 3.0
    import QtQuick 2.0
    
    GameWindow {
      id: gameWindow
      screenWidth: 960
      screenHeight: 640
    
      Loader {
        source: "http://felgo.com/support/MainContent.qml"
      }
    }
    

    The MainContent.qml file has the following content and is on our servers:

    import Felgo 3.0
    import QtQuick 2.0
    
    Scene {
      id: scene
      width: 480
      height: 320
    
      Rectangle {
        id: rectangle
        anchors.fill: parent
        color: "grey"
    
        Image {
          source: "vplay-logo.png" // this url is relative to the qml document's url, so it's taken from our server as well
          anchors.horizontalCenter: parent.horizontalCenter
          anchors.top: parent.top
          width: parent.width
          height: 100
          fillMode: Image.PreserveAspectFit
        }
    
        Text {
          id: textElement
          text: "Hello Remote Felgo World"
          color: "#ffffff"
          anchors.centerIn: parent
        }
      }
    }
    

    Is this sufficient for your use-case?

    Cheers,
    Alex

    #14493

    Bas

    hi Alex,

     

    thanx for the fast reply, as always 🙂

    yes this is what i had done in a working example, and works good.

    then i have put in a factory for network access management.

    engine.setNetworkAccessManagerFactory( new MyFactory());

    #ifndef MYFACTORY_H
    #define MYFACTORY_H
    
    #include <QObject>
    #include <QQmlNetworkAccessManagerFactory>
    #include <QNetworkAccessManager>
    #include <QNetworkDiskCache>
    
    class MyFactory : public QQmlNetworkAccessManagerFactory
    {
    public:
        QNetworkAccessManager* create(QObject *parent)
        {
            QNetworkAccessManager* manager = new QNetworkAccessManager( parent );
            QNetworkDiskCache* cache = new QNetworkDiskCache(manager);
            cache->setCacheDirectory("tmp/cache/");
            manager->setCache(cache);
            return manager;
        }
    
        MyFactory();
    };
    
    #endif // MYFACTORY_H
    

    but his works on desktop, did not tried on mobile device. and i think i need to change the cache directory.

    gr, Bas

    #14494

    Alex
    Felgo Team
    #14495

    Bas

    ah great!

    #14496

    Bas

    is there some way to track if all loading (including gfx and other data) is done?

    #14497

    Alex
    Felgo Team
    #14498

    Alex
    Felgo Team

    Also I think that the asynchronous property of the loader defaults to true for remote urls, which means you can actually see the qml source loading item by item, so you might want to set visible of the Loader to false while the loader is not ready, and show a loading animation instead.

    #14499

    Bas

    cool that works good,

    #14500

    Bas

    is there anything that could be different when creating an app this way?

     

    #14501

    Alex
    Felgo Team

    You will see 😀 We didn’t try something like this excessively, so not too much of experience we can share there. Keep us updated on how it is going!

    Cheers,
    Alex

Viewing 11 posts - 1 through 11 (of 11 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded