Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Can a QML file refresh a JS import at runtime?
Forum Updated to NodeBB v4.3 + New Features

Can a QML file refresh a JS import at runtime?

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qttester5
    wrote on last edited by
    #1

    Is there a way to have a QML file re-import a JS file at runtime? For example, I have this line at the top of a QML file:

    @import "qrc:/someJSfile.js" as MyJS@

    Now, suppose new functions are added, or existing functions are edited in that JS file while the Qt app is running. Javscript is a dynamic language that offers runtime evaluation, but I wonder how I could have the QML file "refresh" its knowledge of those functions without restarting the app?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lack
      wrote on last edited by
      #2

      Yes.
      use Qt.Include()
      see "this":http://qt-project.org/doc/qt-5/qtqml-javascript-imports.html#including-a-javascript-resource-from-another-javascript-resource

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved