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. Problem with import Javascript

Problem with import Javascript

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.5k Views
  • 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.
  • F Offline
    F Offline
    fermatqt
    wrote on 18 Apr 2016, 15:07 last edited by
    #1

    hi!

    i have a problem with javascript.
    i created a Qt Quick Controls Application, and than i have created a script.js with qctreator.
    this file was automatically created in Other files directory.

    on my main.qml i have added this line:

    import QtQuick 2.6
    import QtQuick.Controls 1.5
    import QtQuick.Dialogs 1.2
    import "script.js" as Script
    

    and this is the error:

    QQmlApplicationEngine failed to load component
    qrc:/main.qml:4 Script qrc:/script.js unavailable
    qrc:/script.js:-1 File not found
    
    The program has unexpectedly finished.
    

    where am I doing wrong ?

    1 Reply Last reply
    1
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 18 Apr 2016, 22:25 last edited by
      #2

      Hi,

      Do you have a .qrc file in your project ? Does it include script.js ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • F Offline
        F Offline
        fermatqt
        wrote on 19 Apr 2016, 07:13 last edited by
        #3

        hi!

        ok, i added the file into the qml.qrc, and it works:

        <RCC>
            <qresource prefix="/">
                <file>main.qml</file>
                <file>MainForm.ui.qml</file>
                <file>script.js</file>
            </qresource>
        </RCC>
        

        thanks!!

        1 Reply Last reply
        0

        1/3

        18 Apr 2016, 15:07

        • Login

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