| ★ wanayoo — archive 1999 http://codeforge.com/tutorials/QtTutorial.html | Nouvelle recherche | Portail wanayoo |
|
|
|
The Qt project is very similar to C++ one. Except using of Qt Meta Object Compiler. Here is a short quotation from 'Qt reference documentation' : The moc reads a class declaration and produces a C++ source file containing the names of all signals and slots for that class (and a little more). This C++ source file the moc outputs must be compiled and linked with the implementation of the class (or it can be #included into the source file).So, you must preprocess your headers and create from them temporary source file, which you must compile by g++ and link to the target. Let's take 'hello' example from Qt distribution. There is header file 'hello.h' and source file 'hello.cpp'. The 'hello.h' file must be passed through moc preprocessor and get 'moc_hello.cpp' as a result: $ moc hello.h -o moc_hello.cppNext step is to compile 'main.cpp', 'hello.cpp' and 'moc_hello.cpp' into one executable.
$ g++ -o hello main.cpp hello.cpp moc_hello.cpp \
-I/usr/lib/qt/include -L/usr/lib/qt/lib \
-L/usr/X11/lib -lX11 -lXext -lqt
You can import an existing makefile from Qt examples (but it won't be converted
too well, these makefiles do not support some of the default macros and conversions,
as they come into conflict with the IDE), but the better way - is to create a new
project and add existing sources from an example. In this case you'll get to
experience all the power of C-Forge (RCS, working versions, default conversions).
To create 'hello' example from Qt distribution in C-Forge you have to take following steps: 1. Create new project with the target name 'hello'
2. Enter target name 'hello' and do not to forget to change target type to 'C++ executable'. Check out 'Use Directory Layout' button.
3. Initialize Qt includes directory search path. Add '/usr/X11/include' and '/usr/lib/qt/include' to Tools Options / GNU C Compiler / Preprocessor Options / Include Directory Search.
4. Initialize library directory search and used libraries list. Add '/usr/lib/qt/lib' and '/usr/X11/lib' to Tools Options / Link Editor / Linker Options / Library Directory Search.
Further, you have two ways (each of them has both positive and negative sides): First:
Second:
|
Copyright © Code Forge, Inc. 1997-99. All rights reserved.
Last modified: Thursday, 30-Sep-1999 02:13:48 MDT