Qt - 'Shadow Building'? - qt

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

Related

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

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.

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.

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

Compiled distribution of Qt application for windows

I was successfully able to compile and run my Qt application. However, when I move the .exe file outside its original path, I found out that I have to manually copy the Qt DLLs (e.g. mingw10.dll, qtcore4.dll). Is there any dynamic way to link these libraries with my application?
I think you mean you want to "statically" link these libraries with your application.
Basically this means that everything will be rolled inside your exe, and you will have no need of those dlls anymore.
There are advantages to to static linking, but there are also disadvantages as well. You should be absolutely sure that this is what you want to do before you go this way.
Check out this link which explains the difference in depth Dynamic Linking vs Static Linking
As for your specific issue, if you are sure you want to use static linking you will have to change your Qt setup to be built statically. By default the Qt distribution is setup to use dynamic linking. There is a handy guide for that here.
Basically when you setup the build you have to run "configure -static" to change all the project settings to use static linking instead of dynamic linking. And then build Qt over again.
You should also verify your Qt license. If you are using the Qt LGPL license and you want to to link statically you will have to include all your object files (.o and .obj) as Mihai Limbășan wisely explained in his comment. If you have bought and paid for Qt, then you have no problem.
If the DLLs are on the PATH for the application, then they will be found and work. So, you could add where your Qt binaries/dlls are into the %PATH% environment variable. If you're going to create an installer for your application, you'll need to either package these libraries in so they're in the bin directory - or you'll have to expect every user to install and possibly compile Qt themselves (hint: go with the first option. :) )

How do you enforce dependencies among java folders in Netbeans?

I am new to Netbeans. I am wondering if someone can help me with project setup in netbeans. I am moving half million lines of Java code from a different IDE to Netbeans. I was able to get the code build and run in Netbeans easily. I have a project with many folders with dependencies among those folders. They have to be built in specific order. This is to enforce layering so that a module in lower layer cannot call into higher layers. I couldn't get that configured in Netbeans. Below is how my project looks like
project/
libA/
libB/
libC/
libD/
libE/
appA/
...
I have one project that builds all the libs and appA. The project build xml is stored under project/ folder. But the libs have dependencies among them. libB should be built after libA. libC after libA. libE depends on libD and libB etc.
I tried to change the order of source folders for libs in project properties. That didn't seem to make any difference. Even if I move libA after libB, it was building everything fine. I expected it to fail because libA didn't build yet.
Iam lost. Just wondering what the trick is to enforce this kind of dependencies. I created my project using "Java project using existing sources" wizard.
I appreciate your help
Thanks
Video guy.
Even though it would be a pain, you could just write your own ant build script and then just have Netbeans use that.
Basically:
write the custom ant build file
install the Ant plugin
create an Ant build file
right click the build file
run the selected target.
This would enable you to enforce whatever you need to do, but, if Netbeans is figuring out the correct order then why not just use it.
Does something break when you just compile and run in Netbeans?
Well! Lets say a team member added piece of code in lower level package that calls into higher layer code. It should fail because it breaks the layering. Because Netbeans seem to compile all the files in one javac invocation, the build compiles just fine. I want Netbeans to break the build in this case.
Writing my own ant script is another way of enforcing it. The whole point in using an IDE is to save yourself from writing your own make files (or ant scripts). This is something any IDE was able to accomplish 10 years back out of the box. I am wondering if I am missing something here.
Thanks
Video Guy

Resources