title: How to most correctly / efficiently refresh an Item whose source has changed?
body: <p>I have a loaded qml file from the file system that changes, however since the first time it is loaded it is also cached, it doesn't refresh even if the <code>Loader</code> is "reset" via setting the source component to <code>undefined</code>.</p>
  
  <p>A <a href="https://stackoverflow.com/questions/19604552/qml-loader-not-shows-changes-on-qml-file">similar questions has been asked before</a>, however I'd like to go further for a few reasons:</p>
  
  <ul>
  <li>the accepted answered there suggest the use of <code>engine-&gt;trimComponentCache()</code> which unfortunately works only once and then stops, no further updates are reflected</li>
  <li>in the comments below, the OP suggests that <code>engine-&gt;clearComponentCache()</code> works, and indeed it does, each and every time. However the documentation for this method has me a little uneasy in regard with its usage:</li>
  </ul>
  
  <blockquote>
    <p>This function causes the property metadata of all components
    previously loaded by the engine to be destroyed. All previously loaded
    components and the <strong>property bindings for all extant objects created</strong>
    <strong>from those components will cease to function</strong>.</p>
  </blockquote>
  
  <p>This certainly sounds ominous, especially the part in bold, since I am not reloading my entire application, it is just a tiny part of a rather big application, which needs to remain in tact while at the same time refreshing that particular external qml file to reflect its changes.</p>
  
  <p>The second part thou sounds a bit more promissing:</p>
  
  <blockquote>
    <p>This function returns the engine to a state where it does not contain
    any loaded component data. This may be useful in order to reload a
    smaller subset of the previous component set, or to load a new version
    of a previously loaded component.</p>
    
    <p>Once the component cache has been cleared, components must be loaded
    before any new objects can be created.</p>
  </blockquote>
  
  <p>So it does give the impression that this method can be used to only reload a subset without breaking the existing code. However, even if that is the case, it will involve a lot of extra work to rebuild all caches for newly instantiated objects, rather than simply cleaning the cache for the particular qml source that changes.</p>
  
  <p>Additionally, I've been thinking about a more complex solution, involving the creation of a custom QML element, which is essentially a wrapper around a whole new QML engine that renders to an FBO and displays the output as an object in my "main" engine, thereby completely isolating the two engines. However I am not all that keen on doing all that extra work, and introducing the overhead of another whole running engine.</p>
  
  <p>So any ideas?</p>