Code::Blocks

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: chameleon on March 01, 2010, 12:45:19 am

Title: Qt support in C::B project (request)
Post by: chameleon on March 01, 2010, 12:45:19 am
The request is the creation of a plugin which compile a C::B project with full Qt support.
I have not the time and knowledge to write it myself, so I give information.

Qt's compilation is strange.
The problem appears with 2 type of files. An *.ui file and an *.h file with special macros.

*.ui files are xml which describe a dialog or a form. Qt transform it to a *.h file with this command:
.\Qt\qt\bin\uic.exe -o ui_maindialog.h maindialog.ui
so the file maindialog.ui translated to ui_maindialog.h

So the C::B must convert *.ui file to *.h and add generated *.h to project.

This is possible via Settings->Compiler & Debugger...->Global Compiler Settings->Other Settings->Advanced Options...->Commands
and for a new extension UI place the command line macro:
.\Qt\qt\bin\uic.exe -o $file_dir/ui_$file_name.h $file
generated files:
$file_dir/ui_$file_name.h
and command:
Compile single file to object file.

All works fine for this type of file. With a minor exception. We define a compilation for this type of file, but a "build" option doesn't appear on file's right click menu.

The other file is *.h with special macros.
So when we find a Q_OBJECT line inside a *.h file we must run the command:
.\Qt\qt\bin\moc.exe -o moc_maindialog.cpp maindialog.h
so the file maindialog.h creates the file moc_maindialog.cpp

So the C::B must convert *.h file with Q_OBJECT line, to *.cpp and add generated *.cpp to project.

This is possible via *.h file's custom build:
.\Qt\qt\bin\moc.exe -o $file_dir/moc_$file_name.cpp $file
but generated file doesn't added to project automatically.
Even if you add it, "Clear project" does not work on it.
Title: Re: Qt support in C::B project (request)
Post by: stahta01 on March 03, 2010, 04:01:57 pm
Please read

http://wiki.codeblocks.org/index.php?title=Main_Page
Title: Re: Qt support in C::B project (request)
Post by: MortenMacFly on March 04, 2010, 06:49:44 am
There are two QT plugins around for C::B. Search the forums / WiKi. I don't recall exactly how they were names... I believe one was qthelper and the other qtworkbench...?!
Title: Re: Qt support in C::B project (request)
Post by: critic on April 20, 2010, 11:44:15 am
You can use QtHelper plugin as MortenMacFly mentioned.
Simply go to the location http://forums.codeblocks.org/index.php/topic,10453.0.html,
download latest attached sources and compile binary for your platform.