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. [SOLVED] import components from qrc
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] import components from qrc

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 1.7k 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.
  • G Offline
    G Offline
    gggfggg
    wrote on last edited by
    #1

    Hi.

    I'm using qrc for my qml files. My main.qml is loaded from main.cpp
    @
    view.setSource( QUrl( "qrc:/qml/main.qml" ));
    @

    I try to import my qml-component in main.qml from qrc too. Disk path to qml-files is ".../qml/main.qml" and ".../qml/Component.qml". Qrc-prefix is "/".

    That's how I try to import:
    @
    import "Component"
    // or
    import "Component.qml"
    // or
    import "qrc:Component"
    // or
    import "qrc:Component.qml"
    // or
    import "qrc:/Component"
    // or
    import "qrc:/Component.qml"
    // or
    import "qrc:/qml/Component"
    // or
    import "qrc:/qml/Component.qml"
    @

    And nothing works. Need help.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Try avoiding to keep QML filename as Component since Component is a predefined type.

      Now, you can directly use the QML file instead of importing.
      For e.g
      If your QML file in qrc is say for e.g NewComponent.qml
      then in main.qml you can use directly

      @
      NewComponent
      {
      id: comp
      }
      @

      157

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vincent007
        wrote on last edited by
        #3

        "To use the resource system in a mixed QML/C++ application: ......":http://doc-snapshot.qt-project.org/qdoc/qtquick-deployment.html

        put your qml files into resource and then no needd use ""qrc:" in your qml code.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gggfggg
          wrote on last edited by
          #4

          Thanks for your replies. Solved.

          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