Author Topic: Qt support in C::B project (request)  (Read 7543 times)

Offline chameleon

  • Multiple posting newcomer
  • *
  • Posts: 39
Qt support in C::B project (request)
« 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.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7576
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Qt support in C::B project (request)
« Reply #2 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...?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline critic

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: Qt support in C::B project (request)
« Reply #3 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.