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 23.8k 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.
  • H Offline
    H Offline
    hoozi
    wrote on 19 Jul 2011, 05:15 last edited by
    #1

    hi,

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

    get a error "Invalid import qualifier ID "

    thx

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rmcm
      wrote on 19 Jul 2011, 06:29 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 19 Jul 2011, 06:53 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 19 Jul 2011, 06:56 last edited by
          #4

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

          Chuck

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hoozi
            wrote on 19 Jul 2011, 08:36 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 20 Jul 2011, 03:10 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 20 Jul 2011, 03:23 last edited by
                #7

                qrc prefix is not the Key. :(

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mbrasser
                  wrote on 20 Jul 2011, 04:19 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 20 Jul 2011, 04:28 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 22 Jul 2011, 15:40 last edited by
                      #10

                      need someone

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        Antonio Ortiz
                        wrote on 20 Jul 2015, 04:24 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