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)"
Related
i developed a qt-project on Qt Creator for Mac OS. Now i want to import this projekt on Windows (Qt Creator, Compiler, libs are already installed).
Compiling the project already works. But when running, it crashes. On Mac I changed some classes in the UI (Qt Creator). So I did the same on Windows. But it still crashes. I also tried to copy the ui_mainwindow.h from Mac to Windows. Doesn't work.
I remembered, that I added some slots in the UI (Qt Creator) to make buttons functional. And only the mainwindow.h and mainwindow.cpp changed (in my gitHub version). But usually you have to add connect(SIGNAL ... SLOT ...) to add functionality to Buttons. So I searched for this functions, and found their names in moc_mainwindow.cpp
And this moc_mainwindow.cpp file is also on windows, but contains different stuff (not my in Mac UI added slots). And when copying my project from Mac to Window the folder doesn't contain moc_mainwindow.cpp. So it has to be build by the system.
Does anybody know how to get the SLOT information from my Mac project to the moc_mainwindow.cpp on Windows. And is the changing of this file enough or do I have to change also other files to get my project work on Windows?
Thanks
you need to run qmake on the .pro file and run make on the generated files
in qCreator you can do this in the build menu
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).
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.
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.
How can I use OF within Qt Creator environment?
I fact , how should I build the lib and add it in my .pro file and all.
I have successfully done a porting of open frameworks project in creator loading plain Makefile projects.
You can add the includes directory in the file projectName.includes to have auto-completition and file navigation (just do it with a find shell command against OF_PATH/libs) and it is very handy.
Moreover config.make and addons.make let you use the builtin project-creation tools and workflow provided by the official community project management system, and also add external binary/libraries/shared components with the standard gcc command (-I for example).
In this way you can use QtCreator and do not care about .pro/.pri files and use the makefile projects (I have tested it both on linux and mac/osx) and I think there will be no problem also with arch compiling.
Also no problem with C++11 (even if I haven't tested all new features of the language).
See this post in the official forum.
Check out this github repository: https://github.com/procedural/ofqmake There is a qmake project file (.pro) if you want to build openFrameworks using qtcreator as well as a qmake include file (.pri) if you want to use oF in your own projects.
This is exactly what you want to do. Get the openFrameworks.pri file and include it in your .pro file by adding include(openFrameworks.pri).
Qt itself provide an open-framework called Qt-Complex. Go through it and you can find how to add a framework to your project there.
To update this topic again, since OF9.0, QT Creator is now officially supported (and even the default recommended IDE!).
See this setup Guide: http://openframeworks.cc/setup/qtcreator/