Important: Please read the Qt Code of Conduct -

How to use import in loaded qml?

  • 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

  • Qt Champions 2017

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

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

  • Qt Champions 2017

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

  • 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.

Log in to reply