How to use qt creator for non qt, non cmake project? - qt

I want to use qt creator for modifying a project that just uses makefiles. How i can do it? Right now i can just open project files one by one and there is no auto code completion or other advantages of ide. My main concern is use the ide over ssh actually.
I tried open all folder but it didnt work too.

You can use Qt Creator for non-Qt projects, but it will always assume you want to use qmake, CMake, or QBS as your build system. It's not going to read your plain Makefiles and recognize what source files you are using.
In the New Project wizard, you can select non-Qt application. I recommend selecting qmake as your build system, which will create a .pro file, even if you won't end up using it. Then after it creates the project, go into your Project settings under Build Steps. You can delete the built-in steps and add your own custom build steps to do whatever you want. Call make or whatever. Do the same for the Clean Steps.

Related

Integrating ros to an existing qt application

I have a QML, OpenCV application on qt5 which uses qmake and has a .pro file. I want to add publishers/subscribers to my qt project to publish video stream and instructions etc. I tried to use catkin_create_qt_pkg command to create a template and transfer my project to the template but there were numerous problems which made me question my approach. The ros-qt template uses Cmakelist and .ui instead of qml. So, I will need to change some things to integrate them.
First, is it possible to use ros with qmake and .pro instead of cmake. It would be easier to add just ros publishers and listeners to my existing application than changing the entire QML application. If not, how do I convert qmake and .pro to cmake and Cmakelist.txt (assuming that I can use QML with ros). Also, although it doesn't sound well, is it possible to use .pro for qt and Cmakelist.txt for ros in the same package?
Second, is it safe to use qt5 and qml with ros? The ros_qt app template uses qt4, not qt5. Here is the app template.

how build the qt project itself using qtcreator

Update:
Because this was partly to have a project to code-browse the whole of qt, here is a much better way to do this: Code Browser by Woboq for C & C++
This even lets you browse into the includes outside the project like the system includes or the standard library.
Old Post:
My question is about Qt project in git://code.qt.io/qt/qt5.git repository. I checked out version 5.12.
My assumption is that qtcreator knows the qmake file but nothing about the configure command. Hence
I used the configure command to prepare the build in a shadow build directory
In QTCreator I opened qt.pro located in the git workspace
QTCreator opens the build settings dialog and I import them from the shadow build directory
Finally I click build in QTCreator.
But the compile window stalls when asking me for input. Qmake asks me about the licence type I want to choose. I had answered that already in the configure phase and even if I would agree to answer the question again, there is no prompt function in qtcreator's compile output window. Where did I go wrong?
If I forget about QTCreator and call make in the shadow build directory, then everything is build fine and without any licensing questions. When I then import the shadow build directory into a QTCreator, then I can build in QTCreator. But then I clicked Run qmake out of curiosity and I was back to square one, i.e. compile window asks me for input again and stops there forever.
Apart from my specific question I found no general documentation about building the qt libraries using QTCreator. I only find descriptions about compiling projects that use the Qt library.
Qt is not really meant to be compiled from within an IDE. However, this does not mean it's impossible to do. There are two ways to archive this:
First approach: Add the developer build as custom kit:
Run the configure script (and add the -developer-build option)
Open QtCreator and go to "Tools > Options > Kits"
Go to "Qt Versions" add press "Add" - select the qmake executable generated by the configure script. Then hit "Apply"
Go to "Kits" and press "Add" - Make shure to select the correct compilers and debugger and select the previously create "Qt Version". Press "Ok"
Open the top level .pro file in QtCreator and choose the previously created Kit. QtCreator will now use the correct qmake executable
This is the "proper" way to go. You can now use the project as any normal project, including changes to pro-files. Also, QtCreator now correctly detects the build directory, so you won't have to change that, even when opening one of the modules.
Second approach: Use as a normal project without qmake:
Run the configure script (and add the -developer-build option)
Run make qmake_all in the same terminal to let Qt prepare all makefiles, create headers etc.
Open the top level .pro file in QtCreator. You can choose any kit.
Go to Project > Your Kit > Build and disable the "qmake" step (the first of the default 2 steps)
Change the "build directory" to be wherever you built Qt - either a shadow build or the source directory
Hit Build and QtCreator will invoke make only, archieving the same behaviour as running make from the console.
This is kind of a workaround and I would not recommend using it for a full Qt build, unless the first approach does not work for you for whatever reason.
This can also be useful if you only want to make changes to a single Qt module, without compiling the whole Qt framework, i.e. you can clone one of the submodules and use your "existing" qmake on it instead of compiling QtBase (in that case, you skip step 4)
Final notice: When I tried opening the whole Qt-Project, QtCreator crashed on my system because the project was to big to handle. I would recommend you to only open one of the modules within the super repostitory, i.e. "qtbase", "qtdeclarative", etc.

qmake subdirs optional target/sub project

I wondering if there is such a thing like optional targets or sub project in qmake, the Qt build tool.
Project
In my test example I have a subdirs project which contains another two projects, one shared library and one basic application. The application depends on the library which works great. Additionally I have one additional compiler (invoking lrelease) and one additional target (invoking lupdate), which also works like a charm (the shared library provides them as pri file for multiple projects).
After a complete build in release mode, the Windows deployment tool (namely windeployqt.exe) is called and deploys the target with all required shared libraries and plugins to my deployment directory.
Last component I wish to add is the creation of an installer using the Qt Installer Framework, which in fact should be easily done one the executables are located. Thus I want to create another sub project which contains all the installer stuff and provides the qmake steps to create one. But the project should not be build all the time but only when I want to, preferably over the create menu of Qt Creator.
Question
Is there any way to make a qmake subdirs sub project fully optional, so it will not be built using the default build all?
You can add a check around it:
enableOptional {
message(optional enabled)
SUBDIRS += YourSubDir
}
And call qmake with
qmake CONFIG+=enableOptional yourProject.pro
The qmake documentation states that one should use the test function requires(condition) to skip building a whole project. Using this one may add a new build configuration, namely bundle as example, which defines a configuration variable as #Jeffrey pointed out in his answer.
I managed to get it working with the following qmake project definition:
requires(BUNDLE_INSTALLER)
TEMPLATE = aux
QMAKE_POST_LINK = ...
Once you define the variable, over a new build configuration for proper working with Qt Creator (example), the steps listed under QMAKE_POST_LINK are performed. So I may bundle the installer, if I want to.

Convert project Qt to file .exe for window

Hello i'm a young develop on Qt. I want to know that can we convert project Qt (header, source, form, resource) to a file can run without Qt Creator? And how can we convert it to a file executable on window (.exe)?
The compiler is responsible for making an executable out of the source code. This has nothing to do with Qt.
When you start a program from the QtCreator an executable file is built by the compiler, then started. Have a look in your project folder to find that .exe file.
You dont have to do anything special. Each Qt project has a .pro file that is used for compiling. You need to use qmake on the command line with the .pro file as input. This will generate a makefile that you can then give to nmake.exe (if using Visual Studio compilers) or mingw-make (if you are uisng mingw compilers) to build. These steps will compile your source code into the .exe. Look through documentation of qmake to know more. Qt Creator also does the same steps and you can check out the buildlog in Qt Creator to see it working.
Yes, the exe file that you compile with Qt Creator or alternatively some other IDE or compiler is technically all you need to run the project from there on, except you need to have the linked Qt libraries somehow available to the executable. This is especially important if you plan to run it on a machine different from the one you developed it on. See the Qt documentation on Deploying Qt Applications for other details you may need to consider in that case.

Qt - 'Shadow Building'?

I have a simple question - what is Shadow Building? I've seen it in Qt in Target Setup dialog, but don't know what it does or if I should use it.
It's also present in Projects tab, under General group.
Shadow building is a technique used to build different Qt builds of the same version for different platforms/compilers/etc. Your compiled build is in a different directory, separate from the original Qt source directory.
I've created a shadow build for my MSVS2010 compiler. If I wanted to, I could create a new build for MinGW in a different build directory.
See the definition here, and more information about configuring your build here.
Additional information for Mateen's answer.
By default, Qt Creator builds projects in a separate directory from the source directory, as shadow builds. This keeps the files generated for each build and run kit separate. If you only build and run with a single kit, you can deselect the Shadow build checkbox.
https://doc.qt.io/qtcreator/creator-build-settings.html#qmake-build-configuration

Resources