Qt is a product of Trolltech. Trolltech is a software company in Norway, mainly developing two products: one is a cross-platform application interface framework; another is to provide an application platform for embedded Linux development, which can be applied to PDA and various mobile devices. . QT and QTOPIA are two representative.
QT is a multi-platform C graphical user interface application framework that provides users with all the elements needed for the beautiful graphical user interface, and it is based on an object-oriented idea, so the user's extension is quite Easy, and it also supports real component programming.
Qt is the foundation of the Linux desktop environment KDE. The author believes that QT is the same, so QT is the same, so QT's greatest advantage is that its cross-platform, can support existing operating system platforms, mainly:
◆ MS / Windows 95, Windows 98, WindowsNT 4.0, Windows 2000, Windows XP;
◆ UNIX / X11 Linux, Sun Solaris, HP-UX, Compaq True64Unix, IBM AIX, SGI Irix, and many other X11 platforms;
◆ Macintoshi Mac OSX;
◆ Embedded - Linux platform with frambuffer.
The following briefly introduces the installation and use of Qt / Embedded and QTOPIA in Linux, as well as some of the issues that may encounter during development.
QT and QTOPIA installation
If you need to install a QTOPIA platform with FRAMBUFFER, you need to have the following software (the listed software is used as an example of the author):
◆ Qtopia 1.6.0;
◆ TMAKE 1.11;
◆ Qt / Embedded 2.3.4 (QTOPIA 1.6.0 is based on the development platform);
◆ Qt / Embedded 2.3.2 for x11;
◆ Qt 3.1.2 for x11.
The free version of the QT / Embedded provided by the company can download on Trolltech's website.
QTOPIA platform installation is divided into the following steps:
Unpack qtopia
Run the following command in Linux command mode:
TAR XFZ QTOPIA-SOURCE-1.6.0 (Unpack) CD Qtopia-Source-1.6.0 Export QPEDIR = $ PWD (Set Environment Variable) CD ..
2. Install TMAKE
Run the following command in Linux command mode:
TAR XFZ Tmake-1.11.tar.gzexport Tmakedir = $ PWD / TMAKE-1.11Export TMAKEPATH = $ TMAKEDIR / LIB / QWS / Linux-x86-G Export Path = $ TMAKEDIR / BIN: $ PATH
3. Install Qt / Embedded2.3.4
Run the following command in Linux command mode:
tar xfz qt-embedded-2.3.4-commercial.tar.gzcd qt-2.3.4export QTDIR = $ PWDexport QTEDIR = $ QTDIRexport PATH = $ QTDIR / bin: $ PATHexport LD_LIBRARY_PATH = $ QTDIR / lib: $ LD_LIBRARY_PATHcp $ QPEDIR / src /QT/qconfig-qpe.h src / tools /. / configure -qconfig qpe -qvfb -depths 4, 8, 16, 32make sub-srccd .. also add -System-JPEG and GIF in Configure's parameters, The QTOPIA platform supports graphics in JPEG, GIF format.
4. Install QT / X11 2.3.2
Run the following command in Linux command mode:
tar xfz qt-x11-2.3.2-commercial.tar.gzcd qt-2.3.2export QTDIR = $ PWDexport PATH = $ QTDIR / bin: $ PATHexport LD_LIBRARY_PATH = $ QTDIR / lib: $ LD_LIBRARY_PATH / configure -no-openglmakemake -. C Tools / QVFBMV Tools / QVFB / QVFB BINCP BIN / UIC $ Qedir / Bincd ..
According to the developer's own development environment, you can also add other parameters in Configure's parameters, such as -no-opengl or -no-xfs, you can type ./configure -help to get some help information.
5. Install QT / X11 3.1.2
Run the following command in Linux command mode:
tar xfz qt-x11-commercial-3.1.x.tar.gzcd qt-x11-commercial-3.1.xexport QTDIR = $ PWDexport QT3DIR = $ QTDIRexport PATH = $ QTDIR / bin: $ PATHexport LD_LIBRARY_PATH = $ QTDIR / lib: $ LD_LIBRARY_PATH ./configure -threadmakecd ..
6. Install QTOPIA
Run the following command in Linux command mode:
CD Qtopia-Source-1.6.xExport Qtdir = $ qtedirexport QPedir = $ PWDEXPORT PATH = $ qpedir / bin: $ pathcd src./configuremake cd ../ ..
7. Install the QTOPIA desktop
CD qtopia-source-1.6.x / srcexport qtdir = $ qt3dir. / configure -qtopiadesktopmakemv qtopiadesktop/bin / qtopiadesktop. ../bincd ..
QT and Qt Designer
These programs are run after the QT / Embedded and QTOPIA is completed according to the above steps.
Running the virtual emulation window of QT: Run the command QVFB &; Qtopia is just a program developed with Qt / Embedded, running the command in graphics mode:
Export Qtdir = $ Qtedir, QPE &;
Such Qtopia's program is running on QVFB, namely Qt virtual emulation window.
Qt / Embedded is a development tool developed for embedded Linux. QT encapsulates some common class, and these classes are named in Q word, such as QString, QDialog, etc. Here mainly shows how to use Qt Designer to design components and generate corresponding code. In QT, the components are divided into complexes, original body, and accessories. In QT, components are composed of some abstract classes, complex components, management component geometric characteristics.
There are three main base classes in QT: QObject, QApplication and QWIDGET.
Programming in Qt, communication between the objects between Signal and Slot is the main feature of QT. It is very similar to the message mechanism in Windows, but the Signal and SLOT mechanism truly implement a message package. When the status of the object changes, issue Signal, inform all Slot Accept Signal, although it doesn't know which functions are slot, Slot does not know which signal can be received. No one corresponds to the relationship between Signal and Slot, one sign can be sent to multiple slot, and Slot can also receive multiple Signals. Slot does not differ from other member functions in addition to Signal. This mechanism is flexible than using the callback function, but it slows down the running speed of the program. However, in front of the current high-speed CPU, this loss is impossible, and it also guarantees the conciseness and flexibility of the program, very convenient.
In the component of Qt, not only the common member variables and member functions, but also define all Signal and Slot related to the component.
To combine components, the easiest way is to use Qt Designer. First start Qt Designer, in Linux Command Mode, type the following command (assuming Qt installed under / usr / local):
CD QT-2.3.2 / bin ./designer
This allows you to start a similar interface similar to the Delphi under Windows.
Then create a QFrame, drag the components you need directly to this frame, I believe that many people have experienced this experience, and they will not be described in detail here. When you have the store, this new component is saved as a file that extension .ui. Assuming the file named Test.ui, use Vi Test.UI to view this file, found that this is a text written in XML language. Below with this test.ui to generate the corresponding Test.h and Test.cpp. Also in this directory, you can see a UIC tool, this is the QT specifically used to generate .h and .cpp files, type the following command in Terminal mode:
. /uic -o test.h test.ui./uic -o test.h -i test.cpp test.ui
At this point, you can see the corresponding Test.h and Test.cpp, which is a class. Of course, this is just some surface things, but also adds corresponding Signal and SLOT to these code to complete the required operations. It is worth noting that the corresponding version generated UI is best to generate code with the corresponding version of the UIC. If the UI generated by Qt 3.1.2, uses Qt 2.3.2's UIC to generate code, and the generated code will be some null functions.
During the general development process, first through this UI generated class, typically called Base above in QT, as described above, called TestBase; then create a class to inherit this Base. It is usually called implementation of type IMPL, such as Testimpl. In this implementation class define the required member functions, Signal, and Slot, because the UI may often need to be modified. If this is done, you only need to modify the UI in Designer, without going to pay attention to these member functions, Signal and Slot. Compiling a QT program inevitably requires Makefile, providing a tool that generates Makefile in QT, which is Tmake. Use TMAKE to write a .pro file according to the written program. .pro file is very simple, there is a fixed format, below is an example:
TEMPLATE = appCONFIG = qtopia warn_on releaseMOC_DIR = tmpOBJECTS_DIR = tmpHEADERS = fcrs.h / structs.h / globalfunc.h / globalvars.h / testimpl.h SOURCES = main.cpp / globalfunc.cpp / globalvars.cpp / testimpl.cppINTERFACES = test .ui / target = fcrs
After generating this .pro file, type the following command in the terminal:
TMAKE -O Makefile Test.pro
A Makefile is automatically generated, and the program written in this Makefile is available.