Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use import in loaded qml?

How to use import in loaded qml?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.1k 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.
  • T Offline
    T Offline
    tshvets
    wrote on last edited by
    #1

    Hi

    Faced with next problem:
    I use component Loader for dynamically loading .qml which is located in different than all project folder. In this qml I want to include other components either located in the same folder or project's folder.
    I tried to use import with both relative and absolut pathes but id does not work.
    Maybe anybody knows the solution?

    Thanks in advance

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Did you look at QmlEngine::addImportPath().. method handle your case ?

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tshvets
        wrote on last edited by
        #3

        Added absolute path by using QmlEngine::addImportPath() but it still does not see qml which located there.

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          Can you show me the directory structure which you are trying, where you are importing etc ?

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tshvets
            wrote on last edited by
            #5

            For testing I created folder D://test_folder. There I have two files test.qml and test_web.qml. test_web.qml id dinamically loaded from project by using Loader component. From test_web.qml I am trying to import test.qml.
            Tried use it without import since both files there are in the same folder. Also tried to use import "D://test_folder". It does not work in both cases.

            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