title: Qt Creator import file not found
body: <p>I am trying to learn Qt QML with Qt Creator. I want to put my javascript functions into a seperate file and 'import' it into the qml world. Have got the code as below for testing how this works.</p>
  
  <p>Trouble is I get the following error when I run the project in Creator...</p>
  
  <pre><code>&gt; Starting
  &gt; /home/dev/docs/projects/Qt/build-XmlModelView-Desktop-Debug/XmlModelView...
  &gt; QML debugging is enabled. Only use this in a safe environment.
  &gt; QQmlApplicationEngine failed to load component qrc:/main.qml:5 Script
  &gt; qrc:/MyFuncs.js unavailable qrc:/MyFuncs.js:-1 File not found
  </code></pre>
  
  <p>I have watched videos and followed the Qt online docs and looked at others code, but I can't see what is wrong.</p>
  
  <p>I can only guess that some sort of path is not set correctly, but in the docs it says the default path includes the directory that the QML file is in. My .js and .qml files are in the same directory. Also I tried editing the resource file, but that crashed it completely.</p>
  
  <p>I tried moving the .js file to different locations, absolute path in the import statement. My eyeballs are starting to fall out now.</p>
  
  <p>Oddly <strong>IT DOES WORK</strong> if I use qmlscene to run main.qml</p>
  
  <p>Can anybody help? Here is my code...</p>
  
  <p>main.qml file:</p>
  
  <pre><code>import QtQuick 2.3
  import QtQuick.Window 2.2
  import "MyFuncs.js" as MyFuncs
  Window {
      id: window1
      visible: true
      Rectangle {
          id: contentArea
          MouseArea {
              id: mouseArea1
              anchors.fill: parent
              onClicked: {
                  MyFuncs.myfunc();
              }
          }
  }
  </code></pre>
  
  <p>main.cpp file:</p>
  
  <pre><code>#include &lt;QGuiApplication&gt;
  #include &lt;QQmlApplicationEngine&gt;
  
  int main(int argc, char *argv[])
  {
      QGuiApplication app(argc, argv);
  
      QQmlApplicationEngine engine;
      engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
      return app.exec();
  }
  </code></pre>
  
  <p>MyFuncs.js File:</p>
  
  <pre><code>function myfunc() {
      console.log("function was called")
  }
  </code></pre>
  
  <p>Thanks for any help. Lost a whole day, just don't know where to go on.</p>