QML module not found error
Solution 1
This Error Ruined My Life
Real Solution for "QML module not found error":
lets say if you have plugins in directory like this, with qmldir inside it
"myproject/modules/mymodule/blabla.qmldir"
you need to import parent directory like this in ".pro" file :
QML_IMPORT_PATH += $$PWD/modules
not like this (this one wont work):
QML_IMPORT_PATH += $$PWD/modules/mymodule
//---------------------------------------------
side note:
this is going to happen in other part of qml too like qmlplugindump you need to give parent directory not exact folder!
but windeployqt is working with exact folder
for example:
qmlplugindump lib 1.0 C:\Users\Administrator\Documents\projectName\3rdparty > C:\Users\Administrator\Documents\projectName\3rdparty\lib\lib.qmltypes
//---------------------------------------------
and second most important part is QML emulation layer
in Qt Creator go to tools->option->Qt Quick->Qt Quick Designer
select "Use Qml emulation layer that is built with the selected qt"
if its already selected look at textbox under that "Top level build path"
it should refer to Qt version bin directory which should be same as plugins Qt version :
..\5.12.1\msvc2017\bin
for me its :(it should be same version as you used for kits and blabla)
C:\QtN\5.12.1\msvc2017\bin
it should not be like this one :
C:\Users\Administrator\AppData\Roaming\QtProject\qtcreator\qmlpuppet
dont forget to deploy after adding new item in plugins(cmd command) :
windeployqt --qmldir C:\Users\Administrator\Documents\projectName C:\Users\Administrator\Documents\build-projectName-5_12-Debug\debug
and plugin dump :
qmlplugindump lib 1.0 C:\Users\Administrator\Documents\projectName\3rdparty > C:\Users\Administrator\Documents\projectName\3rdparty\lib\lib.qmltypes
after this point if QtCreator gives error for new Objects in Plugins you need to restart QtCreator thats it!
if still there is problems you need to - Clean All - Run Qmake - Rebuild all which solves so many issues.
and in some cases you need to put your qml files into 5.13.1\msvc2017\qml
or whatever is for your qt version
Solution 2
Have you tested this plugin fully? I ask this because I have written a number of plugins and have run into this issue multiple times. Possible issues include the version of Qt you are using, and some form of naming error in the plugin uri / classname.
I have an app that I build for multiple versions of Qt and it seems that the qmlplugindump tool has different levels of effectiveness.
Sorry to be so general, but hopefully it points you in the right direction.
Solution 3
From within QtCreator, do a "project-clean", and then rebuild. The module will be found.
I had the same problem and stumbled onto your question. After some effort, the "clean" and rebuild worked.
There seems to be an "incomplete-dependency-checking" during the build process to "understand" that the main.cpp
needed to be rebuilt, which would then expose the qmlRegisterType<MyType>()
so that it can be found within the main.qml
.
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on July 09, 2022Comments
-
Admin almost 2 years
When using QtCreator, I display a qml file in the editor. The qml file is for a file named
main.qml
that is a plugin.I then click on the
Design
button. It displays the error message:QML module not found
.If I take the
Go to error
link it goes to a line containing the followingimport com.name.os.app.all 1.0
. This is the location of various component qml files needed by the plugin.I have added the path
c:\users\me\ui\viewer\
to myQML_IMPORT_PATH
env
variable. If QtCreater appends thecom.name...
from the qml file import statement to the pathname I added toQML_IMPORT_PATH
, it would find the desired directory. It doesn't.The project uses qmake.
I have tried using
qmlplugindump.exe
to generate aqmltypes
file for my main qml view container file, butqmlplugindump.exe
gives me an error saying thecomponent is not ready
andfile::///c:/Users/name/ui/viewer/modules/app/qml/com/name/os/app/all/typelist.qml:2:1 module MyViewContainer.qml is not installed
.The command I used was
qmlplugindump.exe MyViewContainer.qml 1.0 c:\users\myname\ui\viewer\modules\app\qml\com\name\os\app\all\ > ...