QML module not found error - qt-creator

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 following import 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 my QML_IMPORT_PATH env variable. If QtCreater appends the com.name... from the qml file import statement to the pathname I added to QML_IMPORT_PATH, it would find the desired directory. It doesn't.
The project uses qmake.
I have tried using qmlplugindump.exe to generate a qmltypes file for my main qml view container file, but qmlplugindump.exe gives me an error saying the component is not ready and file::///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\ > ...

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

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.

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.

After two days of googling and headache, thanks to #MoreMag, I finally worked it out! I just write down some key points here, hoping to help you guys! 😀
Problem:
Solution:
â‘  go to Tools -> Options -> Qt Quick -> QML Emulation Layer.
â‘¡ check Use QML emulation layer that is built with the selected Qt
â‘¢ click Browse button choose the Qt building environment bin folder. The path is in the form of D:\Qt\5.15.2\msvc2019_64\bin. Here I'm using the msvc2019 64bit building environment.
â‘£ click Apply button and restart the Qt creater. Done!
Qt Creator document says
A QML emulation layer (also called QML Puppet) is used in the Design mode to render and preview images and to collect data. To be able to render custom types correctly from QML modules, the emulation layer must be built with the same Qt version as the QML modules.
By default, a fallback emulation layer is provided by Qt Creator and built with the same Qt version as Qt Creator. Therefore, your QML modules will mostly not work out of the box.
I guess this issue is caused by the fact that the default QML Emulation layer may not be compatible with some QML modules. In my case, it's QtMultimedia module.

Related

Code::Blocks & WxWidgets Matching Release configuration

I am attempting to start a new project in Code:: Blocks (v17.12) using WxWidgets (v3.1.3) on Windows (10).
(For context, I am new to compiling- I'm a script coder trying to branch out. So... don't be afraid to talk to me like I'm an idiot. I'm prepared to accept that possibility.)
I downloaded the official 3.1.3 source, expanded it to "D:\code\wxw"
I successfully compiled it using mingw32-make that came with Code::Blocks-- there is a directory "D:\code\wxw\build\msw\gcc_mswudll" and "D:\code\wxw\lib\gcc_dll", the latter containing .dll files.
So I go into code blocks, and I:
Create New Project -> wxWidgets Project
Select wxWidgets 3.1.x
Project Title "HelloWorld", under D:\code\C++\tinker-- everything else autofilled.
Project details-- my info.
Preferred GUI Builder - None. Application Type - Dialog.
wxWidgets' location: D:\code\wxw
Compiler: GNU GCC
Selected "Create Release Configuration" because that's how it was compiled.
It provides an Output dir of "bin\Release\" and an Objects output dir of "obj\Release\", which I do not change.
Selected use DLL, built as monolithic, and enable Unicode-- the latter matching my compile settings.
When I click next, it tells me "A Matching Release configuration cannot be found in the wxWidgets directory you specified. This means that the Release target of your project will not build."
I've found multiple hits searching on this error message, but they all devolve into discussions of monolithic vs polylithic compiling and critique of other compiler settings and not actually addressing the problem.
EDIT:
Based on http://wiki.codeblocks.org/index.php?title=WxWindowsQuickRef
I used the following settings for compiling. I set them in config.gcc
BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1 CXXFLAGS=-fno-keep-inline-dllexport
The most important page of the wizard is the 8th page. Based on the settings you gave above, it should look exactly like this:
Also, instead of giving the path on the 6th page, I would define a global variable named wx in codeblocks like this:
Then on the 6th page, you would enter $(#wx) instead of the actual path. This will make using your projects much easier if you ever upgrade the wxWidgets library. You'll only need to change the location in the global variable settings.

Qt Creator: Projects that use other projects as libraries

I've written a small library as a Qt project using Qt Creator, now I want to create a small GUI application that can be used to test it as part of the development process, so it could be like this:
Project root at:
~/code/mylib
Library project and associated code:
~/code/mylib/corelib/corelib.pro
GUI test tool and associated code:
~/code/mylib/libgui/guitool.pro
So far I've only been able to make things work by setting up LIBS+= in the GUI project's .pro file, manually building the library, copying the library's .a file to the GUI directory, and rebuilding the GUI project. A tedious process. Worse: I'm developing the project now on Linux but need to make it build on Linux and Windows, and this manual build style will probably make that harder.
I suppose there's a way to do make Qt Creator aware of the relationships between the projects, so for example building the GUI tool in debug mode use the debug version of the library, or making changes to the corelib would necessitate a build in the GUI, building on some OS would use the libraries OS-configuration...etc
This kind of thing is a couple of clicks away in Eclipse and Visual Studio, but I can't seem to get it working in QtCreator. I've tried "Add library->Internal library" and creating a 'subdirs' project but neither seems to work. I feel it's probably a simple step that I'm missing somewhere, any help?
Try again to use subdirs feature. It have own wizard "Project with subdirectories", but in your case it's easier to write it manually (in example I've added "ordered" to ensure that order of compilation is always correct).
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = corelib guitool
Than you can add libary to your GUI application with wizard (accessible from context menu inside .pro).

Installing Qt 5.0 from source

I have recently used git to get the qt source code and I'm now slightly lost on what to do. I've been following the instructions on this page - http://qt-project.org/wiki/Building_Qt_5_from_Git and I'm on windows 7.
I am at the 'Configuring and Building' stage now from the above link and have just finished the 'mingw32-make' step (about 2/3 down the page, just before the Building Qt Webkit step, which I won't be doing). So I left it running overnight and came back to it seemingly completed, as in there were no errors, failures, that I noticed on the command window output.
So my qt folder (installed at C:\Qt\qt5), looks something like this
http://i.imgur.com/dgcl99w.png
So here's a similar question asked on Stack Overflow that I've found, How to install Qt on Windows after building?.
I've done step 4, which was to add QMAKE_INCDIR += "." to the qmake.conf file inside the qtbase\mkspecs\win32-g++ folder. But now I need a bit of advice as to what to do next.
I already have Qt 5 installed from binary which I did months ago but before I delete that I would like to make sure this building from source plan is going to work right. So I also have Qt Creator and simply put, I would like to be able to open this and create a Qt project after I delete my binary installed version of Qt. How do I do this? I would have thought maybe put a path variable but I'm not sure where to put the path to. Do I need to change any settings inside Qt creator? Is the image above what I should be seeing, or is there some step I have still yet to take to finish build/install.
Thanks
I think you will have to setup your System Environment variables to your new QT bin directory and if your using Qt creator then point to this new QT setup in the project build settings, you'll basically point your Qt version with qmake and then make sure the tool chain contains the complier.

Application won't launch from Creator

my Qt application won't launch from Qt Creator, however I can run the .exe directly from the release folder. Why is that ? I am totally lost here. In Qt Creator, I just get a message telling me that my application just crashed, with the code -1073741515.
Qt Creator must be pointing to the wrong dlls. You could reinstall the QtSDK and it should fix finding the runtime dlls in the IDE (Qt Creator).
http://www.daniweb.com/.../ok-so-whats-error-1073741515-again
On this post here they said they fixed it by updating the PATH in Qt. Here is the portion that gets prepended to my PATH variable as seen in the picture below:
C:\QtSDK\mingw\bin;C:\QtSDK\Desktop\Qt\4.7.3\mingw\lib;C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin;
Here is a screenshot showing how to access that:
Another option is you could go into the QtSDK folder, find the bin folder for compiler and platform you are using and put it in the path for your system. Then Qt should be able to run the program just by finding the dlls in the system path.
Possibly the shortest option, but the trickiest would be to go into Qt Creator > Tools > Options > Qt4 and make sure you have something that looks similar to this:
.
Going by this answer it looks as if it's failing to find a shared library.
Check the appropriate path environment variable in the project's run settings and make sure it's got everything it needs.

Adding QT Form to an existing VS2008 project

I have a normal VS2008 project that I've been working on for awhile that is doing some OpenGL based stuff. The main window is created with GLUT and until now that has been sufficient for my GUI.
Now, however, I want to add a small window of buttons, and I need to do it in a cross platform way, so I decided to use QT. I've installed all of the QT components including the VS add-in and everything seems to work fine, but I can't figure out how to add a QT form to my project (since it wasn't originally configured to use QT). I really don't want to create a new project in QT Creator and migrate all of my existing code into it, since I already have development environments set up and configured correctly for this code base on three different platforms. Is there some way to tell visual studio to just do the right thing with the .ui file so I can use it in my existing project?
EDIT: By the way, when I say I can't figure out how to add a QT form to the project, I am able to add a form--meaning a .ui file--that when clicked on opens the QT designer. What I can't figure out how to do is make it compile. It has a "custom build rule" added by default, but the command line is blank, and I don't know enough about qmake to get it to build the .ui file for me.
I use these line as custom build rule (where $QTDIR is the location of your Qt installation):
"$(QTDIR)\bin\uic.exe" -o ".\tmp\ui_$(InputName).h" "$(InputPath)"

Resources