Import says QML module not found.
-
I decided to try and use the new method of reqistering so I added QML_ELEMENT to my C++ header file for the class ImportData.
Then I added to my pro file
CONFIG += qmltypes
QML_IMPORT_NAME = ImportFltData
QML_IMPORT_MAJOR_VERSION = 1and added import ImportFltData to the qml file but QML complains QML module not found (ImportFltData) but the application runs. I also tried putting the class name ImportData for the import name and that does not run at all.
I've seen posts saying set QML2_IMPORT_PATH but they never tell you what to set it to.
So how do I get rid of this error other than going back to the QMLRegisterType.
-
@RangerQT
Are you creating a QML plugin or do you simply register the QML type directly in your application and intend to use it there? -
@RangerQT
you mean importing works , but its just about the warning in QtCreator? -
@RangerQT
basically you can ignore this warning, since it is only created by QtCreator, which cant find the module in the the default import paths.
In you .pro file you can set theQML_IMPORT_PATH
variable with a path containing a folder namedImportFltData
. This folder should contain a qmldir file. I think its enough if the qml dir file contains just themodule
specifier -
Okay. Do I use QML_IMPORT_PATH or QML2_IMPORT_PATH. I've seen references to both but there were a bunch of different answers on what to do and all conflicting.
The ImportFltData is the cpp file that's in the same file as the main.cpp, qml files, header files so I point it to that I assume?
I'll have to look up qmldir with the link you gave and see what it does. I've not used that. Hmm. I was assuming I could just define it in the pro file and it would find it but I guess QtCreator needs to be fixed to do that. If that was all that was needed that makes things simpler but if I had to create the qmldir file and all that is in it then I can just use RegisterType until it's fixed if it ever is.
Thanks. I appreciate the help.
-
@RangerQT
as i said you can ignore this warning, it actually has not much of a meaning.QML_IMPORT_PATH
is a qmake variable only used by QtCreator
QML2_IMPORT_PATH
is an environment variable used by the qml engine during runtime.The
module
specifier and also the folder must be named according to your import path ->ImportFltData
-
@RangerQT
QML2_IMPORT_PATH
is NOT an option for your issue, btw
onlyQML_IMPORT_PATH
-