I attached a simple project which is an exact port of the qt example below to cb build system:
http://doc.qt.io/qt-4.8/qt-designer-calculatorform-example.htmlObviously a prebuilt qt4 library is needed to compile the project. To make things easier please create a 'qt4' entry in 'settings->global variables' with the following settings:
base: path_to_qt_library
include: $(#qt4)\include
lib: $(#qt4)\lib
bin: $(#qt4)\bin
Before trying the project please make sure the following entries in 'settings->compiler->other settings->advanced options->commands' are in place for the project's compiler:
1- Create a new extension named 'ui' with:
command line: $(#qt4.bin)\uic.exe $file -o $(project_dir)tmp\ui_$file_name.h
generated files: $(project_dir)tmp\ui_$file_name.h
weight: 30
2- Create a new extension named 'moc' with:
command line: $(#qt4.bin)\moc.exe $file -o $(project_dir)tmp\moc_$file_name.cpp
generated files: $(project_dir)tmp\moc_$file_name.cpp
weight: 40
Note: There is no need for a file with an 'moc' extension in qt. The 'moc' entry will be used to facilitate the configuration of files including a 'Q_OBJECT' macro and its purpose will be clear later.
I marked the new features with '(x)' in the demonstration below with their numbers in my post here:
http://forums.codeblocks.org/index.php/topic,20043.msg137653.html#msg1376531- Load the project, there should be 3 files; 'main.cpp', 'calculatorform.cpp', 'calculatorform.h'
2- Add the file 'calculatorform.ui' in the project's folder to the project, when added it's weight should be '30' (1)
3- File 'calculatorform.h' contains a 'Q_OBJECT' macro so it must be compiled with qt's moc compiler. Make sure the project's compiler is selected during this step.
a- Select file properties by right-clicking on file 'calculatorform.h' in 'management->projects' and clicking 'properties'.
b- Go to 'advanced' tab.
c- Check 'use custom build'.
d- Check 'use settings from extension'. (3)
e- Select 'moc' from the drop-down box. (3) The 'custom build command' and 'generated files' (2) settings from the 'moc' entry in advanced compiler options will be set for the file. Hence the 'moc' entry in advanced compiler options.
f- Click 'ok'.
4- Now as everything is set, hit 'compile'. After the project is compiled, check the project's folder to find the auto-generated files 'ui_calculatorform.h' and 'moc_calculatorform.cpp' under the 'tmp' folder (4). Even if 'tmp' folder doesn't exist, it will be created during the build process (5).
5- Clicking 'build' again won't build the project again unless any of the source files (source or custom extension) is changed. (6)
Some notes:
1- Build files (generated files box in 'file properties->advanced' tab) may sometimes require the project to be reloaded if they are modified. That's because of the current implementation of file properties. In the current implementation, even if the user chooses to cancel the changes, they are saved to the original file the moment the compiler is switched when 'custom build command' is not empty. I believe a proper implementation would require a copy constructor for 'ProjectFile' class (or some copy function etc...) to make a temporary copy to work on. I'm not experienced enough with the contents of 'ProjectFile' to implement one, sorry.
2- There is a bug occuring sometimes giving the error 'moc_somefile.o not found'. Cleaning and reloading the project works but I wasn't able to reproduce it. So if anyone can reproduce, please post the steps and I'll try to investigate.
3- Please ignore my previous patches on this thread as they do not cover some of the bugs correctly.
4- As mentioned many times previously, none of these features are qt specific. They can also be used with other tools in general.
5- My tests are only on windows. Although much of the code is platform independent there are some parts that needs to be tested under other suported OSes.
Thanks.