Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Michael on March 31, 2006, 05:14:26 pm

Title: Using C::B to build Qt applications
Post by: Michael on March 31, 2006, 05:14:26 pm
Hello,

I have just converted a Qt project from Visual Studio .NET 2003 to Code::Block. So, I would like to share my experience. May be it could be useful to other users :).

The project was relatively simple: main.cpp (main application file), CDITool.h, CDITool.cpp and CDIToolDefault.ui (user interface file. Created by the Qt Designer).

Please note that this case concerns the conversion of an already existing Qt project. The CDITool class is derived from CDIToolDefault class "automatically created" by Qt Designer. The creation of a derived class was a necessary step, because all changes made in the CDIToolDefault class files will be lost. 

I am using C::B rev2285, MinGW with GCC 4.1.0 and Qt 3.3.4 (independent version compiled with MinGW-GCC 3.4.2. See here (http://sourceforge.net/projects/qtwin). Please note that the original project was developed with Trolltech Educational Qt 3.3.3 version).

What I have done:


Quote
$(#Qt)\bin\uic.exe ".\CDIToolDefault.ui" -o ".\CDIToolDefault.h"
$(#Qt)\bin\uic.exe ".\CDIToolDefault.ui" -i ".\CDIToolDefault.h" -o ".\CDIToolDefault.cpp"
$(#Qt)\bin\moc.exe ".\CDIToolDefault.h" -o ".\moc_CDIToolDefault.cpp"

One command per line.
Do not forget to check the box "Use custom command to build this file" in the Advanced tab and the box "Compile file" in the General tab :).


Quote
$(#Qt)\bin\moc.exe CDITool.h -o .\moc_CDITool.cpp

Do not forget to check the box "Use custom command to build this file" in the Advanced tab and the box "Compile file" in the General tab :).


I got a lot of warnings :(. Probably because I am using GCC 4.1.0 :).

If you have questions/comments/critics, you can post them here.

Best wishes,
Michael

PS.: If you want to create a Qt application from scratch, you can just create a main.cpp file and one or more .ui files (using the Qt Designer). Then by using the uic.exe and moc.exe tool you create the .h, .cpp and moc files and add them to your project. Anyway, for more info you can visit the Trolltech website (http://www.trolltech.com/).

A last remark: I did not use Qt project file, i.e., .pro file. I have never used them and probably I will continue not to use them :).
Title: Re: Using C::B to build Qt applications
Post by: Boris on June 05, 2006, 12:07:48 pm
Qt 4.1.3
Code
  $(#Qt)\bin\uic.exe ".\CDIToolDefault.ui" -i ".\CDIToolDefault.h" -o ".\CDIToolDefault.cpp"

Not work????
Title: Re: Using C::B to build Qt applications
Post by: Michael on June 05, 2006, 05:51:42 pm
Qt 4.1.3
Code
  $(#Qt)\bin\uic.exe ".\CDIToolDefault.ui" -i ".\CDIToolDefault.h" -o ".\CDIToolDefault.cpp"

Not work????

Hello,

What exactly does not work? It works fine for me (both with C::B and M$ VS C++ .NET 2003).

Best wishes,
Michael
Title: Re: Using C::B to build Qt applications
Post by: Boris on June 06, 2006, 06:37:59 am
Sorry for my english,
Code
Qt user interface compiler 4.1.3.
Usage: D:\Qt\4.1.3\bin\uic.exe [OPTION]... <UIFILE>

  -h, -help                 display this help and exit
  -v, -version              display version
  -d, -dependencies         display the dependencies
  -o <file>                 place the output into <file>
  -tr <func>                use func() for i18n
  -p, -no-protection        disable header protection
I can't see "-i". Key "-i" not work.
Title: Re: Using C::B to build Qt applications
Post by: lfm on June 06, 2006, 10:19:14 am
Please use QT4, because QT4 had changed very much  from QT3
Title: Re: Using C::B to build Qt applications
Post by: yop on June 06, 2006, 08:02:08 pm
Qt 4.x uic does not output implementation files anymore (.cpp files) and the -i switch has become obsolete. In Qt 3 it works fine. The rest of the steps that Michael proposes should work fine though.
Title: Re: Using C::B to build Qt applications
Post by: Michael on June 20, 2006, 08:20:30 pm
Qt 4.x uic does not output implementation files anymore (.cpp files) and the -i switch has become obsolete. In Qt 3 it works fine.

Hello,

I did not know :oops:. Thank you for pointing that out :).

Best wishes,
Michael