3

When I import qml from qrc (which place in different directory from ) it's compile and work fine. But when Qt Creator don't recognize imported component and don't hightlight this.

This's code:

import QtQuick 2.0
import "qrc:/qml_libs/ApplicationContainer"

Item
{
    id: root_object
    width: 300
    height: 200

    ApplicationContainer {
        width : parent.width
        height: parent.height
    }
}
Aleus
  • 83
  • 6

1 Answers1

2

@Aleus, your way of doing thing is little bit tricky. I can't find any information of such kind importing in official documentation (please, take a look at Importing statements in Qt 5.2, QML. Also, take a look at QML Best Practices: Coding Conventions

First of all, check weather your file ApplicationContainer really has no extension (I mean .qml)

To make QtCreator recognize imported component do next things:

  • Add your qml file to .pro file in section OTHER_FILES like this:

    OTHER_FILES += qml_libs/ApplicationContainer

  • AND/OR place statement for importing whole directory to your qml file, like:

    import "qml_libs" as MyLibs ... MyLibs.ApplicationContainer { ... }

Hope it helps!

NG_
  • 6,895
  • 7
  • 45
  • 67
  • I packed qml to qrc because it's boost loading speed in mobile devices and it's easy way to import qml from other library-project. How to use qml in qrc is write this: http://stackoverflow.com/questions/13568437/how-to-use-qrc-in-c-and-qml-application – Aleus May 08 '14 at 01:58
  • I know what is qrc and how to use it. Have you tried to do as I describe? Does it solve your problem? It must make QtCreator to reconize imported qmls. For debug version of your project it is easy way. In release you can comment includes in pro file. – NG_ May 08 '14 at 07:39
  • Yes. QtCreator was parse ApplicationContainer when I add qml_libs.pri (which contain ApplicationContainer.qml and qml_libs.qrc) and reboot QtCreator. – Aleus May 12 '14 at 02:10