Qt Creator: is there something like VS solution in which you can add projects and set project dependencies and build order? - qt

I have one of the latest versions of Qt Creator.
is there something like VS solution? In which you can add projects and set project dependencies and build order?
if I have multiple open projects, how do I set one of them as "default", so that Ctrl+B builds specifically that project?

I think the "solution" you are looking for is the project_name.pro.user file that gets created when you open a .pro file in QtCreator. It's an XML file that describes build steps, build environment, etc. for your project. When your project is open in QtCreator, go in the "Projects" tab (from the left), then in the "Dependencies" tab, where you can check all other (open) projects that this project depends on, and thus must be built first. You can repeat for each project, then QtCreator will figure a build order that satisfies all dependencies (unless there are cyclic dependencies).
Go in the "Projects" tab (on the left), then select the project you want to be "default" from the top bar, and go back in Edit mode. The project you selected will show in bold in the project sidebar, which means it's the one tied to the "Build project" shortcut.

Related

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.

How to select building target in QT Creator?

I am trying to set up and run an open source application(LibreCAD) and I am following their Build From Source guide. In section "Building LibreCAD 2.0 on Windows" and under "Building LibreCAD in Qt-Creator" they state this:
Take care about the Shadow build option in Debug and Release
configuration. Disable this option in both configurations and save the
project.
Select librecad as building target in Qt Creator (instead of tff2lff, which is another choice)
If everything is good up to this point, you can build and run LibreCAD
within Qt-Creator.
I could not figure out how or/and where to do the second task. Could anyone help me please?
In Qt - Building for Multiple Platforms they say I need to "1.Click the Build and Run Kit Selector icon" and then to "2.Choose Build > Build Project". But I don't see any Kit Selector icon on my QT compiler!
And in Configuring Projects they say it is right here:
But on mine, it looks like disabled:
Edit:
This is how my "Kit Selector" looks like:
and then to "Choose Build > Build Project"
I'm not sure where you see that, but it's not on either of those pages.
They're talking about this thingy:
The "Build and Run Kit Selector icon" is on the button above the "Run" button (it's probably named like this because running an executable via this button implies that the target is built first).
In your project, tff2lff might be where app is in the screenshot, and librecad might be where test is, for example.

QtCreator Build doesn't update UI changes in design form

My Qt project uses shadow build.
When I change in MainWindow form ( .ui file), I build the project but my program doesn't update GUI.
If I rebuild all, GUI will be updated. But rebuild is very very slow.
I try creating a new project (an empty QMainWindow with some labels), I modify some texts. I build and GUI is updated.
How can I use shadow build correctly, without a rebuild of all my project?
The same issue occurs if the *.ui file name is changed.
For example, Changing yourUi.ui to myUi.ui.
If that is the scenario, then the ui_*.h should also be changed, that is, yourUi.ui to ui_myUi.h.
close Qt creator, go to your project directory and delete the .pro.user file, open the project again and this time Qt creator will ask you to configure your project by choosing the kit you use to build your project. Select the appropriate kit and press the "configure project" button. Apply your shadow build. I hope it will work.
Have you tried to just run qmake (Build -> Run qmake) ?
Edit
As suggested by a comment, I copied the comment to preserve it.
It seems that QtCreator correctly rebuild the .h file of the ui in the shadow build directory, and then include the ones in the source directory, which is not regenerated. I don't know if this is a bug or an intended behaviour, but a quick workaround can be to build the project in the shadow build directory, copy the generated .h files back in the source directory and rebuild again. This work with my simple project, don't know if can be workable also for bigger and more complex project. Or do not use shadow builds

android studio adding extern jar library

I would like to add the extern jar library commons-jexl-2.1.1.jar. I copied the jar into the libs/ folder and performed the Add as library... menu point. I don't receive any errors in the code and everything seems to work but when compiling and starting the application I receive the error java.lang.NoClassDefFoundError: org.apache.commons.jexl2.JexlEngineon this line private JexlEngine jexl = new JexlEngine();
Does anyone know what I've missed?
Unfortunately, that menu command is doing the wrong thing for Gradle-based projects, which I assume yours is. (Gradle-based projects are what you get when you create new projects in Android Studio). I've filed bug https://code.google.com/p/android/issues/detail?id=62249 to request implementing this menu command properly for these projects, or at a minimum disabling it until it's implemented to prevent confusion.
In the meantime, you can add external JAR dependencies by going through the Project Structure dialog, which will add the appropriate entries to your build.gradle build file. Choose File menu > Project Structure, and click on the "Modules" entry on the left. Choose your module from the middle list, and click on the Dependencies tab on the right. Then click on the + button at the bottom to add a new dependency. Screen shot here:
The + menu has an option for "File dependency" (pictured). You will get a file chooser that will let you select the jar file.
If your dependency is one that can be found in Maven, you may find it more convenient to specify the Maven coordinates; that way, the build system will automatically download the dependency, and you won't have to download and store the JAR manually. To set that up, choose "Maven dependency" from the + menu. You'll get a dialog where you can search to find the proper Maven coordinates for your library. In your case, those coordinates will be "org.apache.commons:commons-jexl:2.1.1#jar"
If you prefer to edit build files by hand, check out your build.gradle file after completing the Project Structure dialog changes to see what it did.
The docs for using Gradle in Android are at http://tools.android.com/tech-docs/new-build-system
courtesy The App Chaps
I've been struggling with the same thing for many hours, trying to get the Gson jar to work no less. I finally cracked it – here are the steps I took:
Put the Gson jar (in my case, gson-2.2.4.jar) into the libs folder
Right click it and hit 'Add as library'
Ensure that compile files('libs/gson-2.2.4.jar') is in your build.gradle file
Do a clean build (you can probably do this fine in Android Studio, but to make sure I navigated in a terminal to the root folder of my app and typed gradlew clean. I'm on Mac OS X, the command might be different on your system
After I did the above three, it started working fine. I think the 'Add as library' step was the one I'd previously missed, and it didn't work until I cleaned it either.
[Edit - added the build.gradle step which is also necessary as others have pointed out]

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