Can anybody explain why import statment behave differently ?
-
in my qml file when i use
below statement it not working
//import Comps 1.0
when i write below statement it works fine
import "Comps" 1.0
it will be great if any body can help why it not working with first statement ?
because 1st statement shows module not installed
-
Hello, some notes:
-
It would be interesting if you could give us a bit more context about what your file hierarchy is so we can answer you more accurately.
-
Normally, when you "import Comps 1.0" it is because the module should be installed (referenced) in: the environment variable $QML_IMPORT_PATH or in the path $QT_DIR/qml for Qt Creator projects or in $QT_DIR/../Tools/<Your Qt Design Studio Version>/qt6_design_studio_reduced_version/qml or otherwise with the call to the qmlRegisterType<> macro.
# make IDEs aware of the QML import path set(QML_IMPORT_PATH ${PROJECT_BINARY_DIR}/qml CACHE PATH "Path to the custom QML components defined by the project") C:\Qt\6.6.2\msvc2019_64\qml\Comps C:\Qt\Tools\QtDesignStudio-4.1.0-lts\qt6_design_studio_reduced_version\qml\Comps qmlRegisterType<CategoryModel>("Comps", 1, 0, "CategoryModel");
- When you do "import "Comps" 1.0" you are importing a relative path from the qml file where you are located.
I hope I have clarified something for you
-
-
@Qt-embedded-developer said in Can anybody explain why import statment behave differently ?:
in my qml file when i use
below statement it not working
//import Comps 1.0
//
marks the beginning of a single line QML comment.