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. Qml and javascript files in resource (qrc), how to import js in qml ?
Forum Updated to NodeBB v4.3 + New Features

Qml and javascript files in resource (qrc), how to import js in qml ?

Scheduled Pinned Locked Moved QML and Qt Quick
11 Posts 5 Posters 24.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.
  • R Offline
    R Offline
    rmcm
    wrote on last edited by
    #2

    try uppercase first letter for the qualifier;

    eg import "qrc:/js/componentCreator" as Ccscript
    
    1 Reply Last reply
    1
    • H Offline
      H Offline
      hoozi
      wrote on last edited by
      #3

      yes,

      @import "qrc:/js/componentCreator" as Ccscript@

      but get another error : "qrc:/js/componentCreator": no such directory

      qrc code here:
      @<RCC>
      <qresource prefix="/qml">
      <file alias="main">qml/CC/main.qml</file>
      </qresource>
      <qresource prefix="/js">
      <file alias="componentCreator">qml/CC/componentCreation.js</file>
      </qresource>
      </RCC>@

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Chuck Gao
        wrote on last edited by
        #4

        @import "qrc:/js/componentCreator.js" as Ccscript@

        Chuck

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hoozi
          wrote on last edited by
          #5

          @import "qrc:/js/componentCreation.js" as Ccscript@
          error:
          qrc:/qml/main:2:1: Script qrc:/js/componentCreation.js unavailable
          qrc:/js/componentCreation.js: File not found

          or, full path

          @import "qrc:/js/qml/CC/componentCreation.js" as Ccscript@
          error:
          qrc:/qml/main:2:1: Script qrc:/js/qml/CC/componentCreation.js unavailable
          qrc:/js/qml/CC/componentCreation.js: File not found

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mbrasser
            wrote on last edited by
            #6

            Hi,

            If your main.qml is also in the resource file, you shouldn't need the qrc prefix for the import. http://doc.qt.nokia.com/4.7-snapshot/qtbinding.html#managing-resource-files-with-the-qt-resource-system gives further details on using the resource system with QML.

            Regards,
            Michael

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hoozi
              wrote on last edited by
              #7

              qrc prefix is not the Key. :(

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mbrasser
                wrote on last edited by
                #8

                Hi,

                Just to clarify, by qrc prefix I meant qrc:.

                I'd also suggest simplifying the qrc file by only using a single qresource prefix, to see if that is introducing any issues.

                Regards,
                Michael

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  hoozi
                  wrote on last edited by
                  #9

                  [quote author="mbrasser" date="1311135597"]Hi,

                  Just to clarify, by qrc prefix I meant qrc:.

                  I'd also suggest simplifying the qrc file by only using a single qresource prefix, to see if that is introducing any issues.

                  Regards,
                  Michael[/quote]

                  thanks.

                  I think this is just a simple question, Is here no one encountered this?

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hoozi
                    wrote on last edited by
                    #10

                    need someone

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Antonio Ortiz
                      wrote on last edited by
                      #11

                      Try to put ".js" in the alias like:

                      <file alias="componentCreator.js">qml/CC/componentCreation.js</file>
                      
                      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