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

Forums

OverviewFelgo 4 Support (Qt 6) › Problem with open asset files on FelgoLive

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #25178

    Jan

    I have some extra configuration files I want to deploy with app and read on app start.

    All works good in normal mode

    QFile cfile(QStringLiteral(“:/qml/appconfig.json”));

    works good and I can open file.

    But not when I switch to HotReload mode – file is not found.

     

    #25180

    Günther
    Felgo Team

    Hi Jan,

    based on the snippet I see that you are loading the qml/appconfig.json from QRC (URL starting with the :/ prefix).
    The QRC resources are not loaded from the file system, but instead compiled within the application binary. Anything that has to be compiled (like C++ code or custom resources) is not directly available with the pre-built Hot Reload Live Client that comes with the SDK.

    To use it with Hot Reload you can:
    * Build your own application that includes all your custom QRC. You can enable Hot Reload for your own project builds with the Live Client Module: https://felgo.com/doc/qml-hot-reload-felgo-live/#how-to-build-your-own-live-client-with-custom-c-and-native-code (note that the config JSON can not be hot reloaded in this case, if it is changed a rebuild is required)

    * Alternatively, you can decide to not add the JSON config as a resource, but just load it from the file system instead. The following line in the Felgo CMakeLists configuration adds all files from the QML and assets folder as resource:

    qt_add_qml_module(appTima URI Tima VERSION 1.0
            QML_FILES ${QmlFiles}
            RESOURCES ${AssetsFiles}
            NO_RESOURCE_TARGET_PATH
    )

    You could move the config to the assets folder and use the deploy_resources(${AssetsFiles}) CMake command instead of the RESOURCES ${AssetsFiles} setting. This way the assets are loaded from the file system and not compiled into the binary. (if you build the project, the deploy_resources command simply copies them to the build folder)

    Hot Reload will be able to transfer and access the JSON config then.

    Best,
    Günther

Viewing 2 posts - 1 through 2 (of 2 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