QT is a product of trolltech. Trolltech is a Norwegian software company that mainly develops two types of products: a cross-platform application interface framework and an application platform for Embedded Linux development, can be applied to PDA and various mobile devices. QT and qtopia are two representative examples.
QT is a multi-platform C ++ graphic user interface application framework. It provides users with all the elements required for exquisite graphic user interfaces, in addition, it is based on an object-oriented idea, so it is quite easy for users to expand their objects, and it also supports real component programming.
QtDifferences between QT/E and qt3 and qt4
The syntax of QT is the same as that of QT/e. the difference lies in the size of the Library Class or the size of the Library Class function. Compared with QT, QT/e does not support a few classes or functions. Whether or not QT/E contains a class or a function in a class. My method is to find it in the include folder under the QT/e installation directory.
There are many differences between qt3 and qt4. The main difference is that the Library Class and supported functions are changed. For example, some functions in qt3 are replaced by other function names in qt4, therefore, many qt4 programs cannot be executed in the qt3 environment. QT/e2.3.7 is basically the same as qt3, except for the differences between QT and QT/e I mentioned earlier.
QT is the basis of KDE in Linux desktop environments. The author believes that the essence of QT is the same as that of MFC in windows. Therefore, the biggest advantage of QT is its cross-platform performance, which can support multiple existing operating system platforms, mainly including:
◆ 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-a Linux platform with frambuffer.
QT/E is: ftp://ftp.rediris.es/mirror/Qt/source/
Tmake is: ftp://ftp.trolltech.com/freebies/tmake/
Download QT
Search and download QT-related packages on trolltech's http://www.trolltech.com/developer/, including
Qt-embedded-free-3.3.4.tar.gz
Qt-x11-opensource-src-4.2.3.tar.gz
Tmake-1.8.tar.gz # can not, because there are now these high versions of QT-embedded, qt-x11, qtopia there is qmake
These are the latest QT versions, and the compilation process seems to be quite different from the steps of the old version when querying data. For example, the new version uses qmake instead of tmake, there are also many changes to the parameters in the configuration of the configure script file. There is no information to check during compilation. In addition to some documents of trolltech, the rest has to be explored by myself.
The following describes how to install and use QT/embedded and qtopia on Linux, as well as some problems that may be encountered during development.
I. concept:
QT/E: A Gui designed by QT for embedded systems. It is directly used for video memory operations and is not required. It is supported by the image library of X11.
QT/X11: it is the GUI of a Linux PC based on QT. It requires support from several libraries such as X11.
QT/win: for Windows
The three source codes are the same. (This is only ideal. If you change the platform, the Code must be rewritten ).
Qtopia (qpe) is an embedded desktop for PDA, which contains a series of applications. You can also put your QT program in qpe and allow the program by clicking the mouse or touch screen.
QtAnd qtopia Installation
If you need to install a qtopia platform with frambuffer, you need the following software (the listed software is used by the author as an example ):
◆ Qtopia 1.6.0;
◆ Tmake 1.11 (or later) Software Package (mainly used to generateQt/Embedded MAKEFILE file of the Application Project)
◆ QT/Embedded 2.3.7 (qtopia 1.6.0 is developed based on this development platform );
◆ QT/Embedded 2.3.2 for X11; (qt's X11 installation package will generate two tools required for the X11 Development Environment)
It should be noted that, because the above software installation package has many different versions, different versions may cause potential conflicts and affect usage. A basic principle is: selectQtForX11The installation packageQtThe/embeedded installation version is old becauseQtForX11The source files generated by UIC and designer areQtThe/Embedded library is compiled together, that is, considering the forward compatibility principle.
Currently,Qt/Embedded can run on various inux-supported processors, including Intel x86, arm, MIPS, and PowerPC processors.Qt/Embedded consumes a low amount of memory because it does not require the X server or xlib library and can directly write buffer frames, you can dynamically adjust unused features during compilation to minimize memory usage. For example, you do not want to use the qlistview library during actual usage. You can defineQt_ No_listview pre-processing mark. It can even compile all application functions to a simple static link executable program.Qt/Embedded provides more than 200 configurable features. The database size range on the intel X86 platform is between kb and kb.
You can download the free version of QT/Embedded provided by trolltech.
Qtopia Platform Installation involves the following steps:
* ***** X86Build/home/software/x86-qt directory
1.Install tmake
Tmake is a MAKEFILE file generator. If you do not compile your own applications, this step can be omitted.
Run the following command in Linux:
Tar-xzf tmake-1.11.tar.gz
Export tmakedir =/home/software/x86-qt/tmake-1.11
Export tmakepath = $ tmakedir/lib/qws/linux-x86-g ++
Export Path = $ tmakeddir/bin: $ path
2.Install QT/X11 2.3.2
Run the following command in Linux:
Tar-xzf qt-x11-2.3.2.tar.gz
CD/home/software/x86-qt/qt-2.3.2
Export qt2dir =/home/software/x86-qt/qt-2.3.2
Export qtdir = $ qt2dir
Export Path = $ qt2dir/bin: $ path
Export LD_LIBRARY_PATH = $ qt2dir/lib: $ LD_LIBRARY_PATH
Echo Yes |./configure-no-xft-platform Linux-G ++
Make
Make-C $ qt2dir/tools/qvfb // generates qvfb, which is a simulated video memory platform.
Make-C $ qt2dir/tools/designer
CP $ qt2dir/tools/qvfb Bin
CP $ qt2dir/tools/DESIGNER/designer Bin
If no UIC exists in CP $ qt2dir/bin/UIC $ qtedir/bin // QT/e, copy it.
CD ..
. The/configure-no-xft clause does not have the-no-XFS Suffix in the youlong document, but if it does not, an error is returned. Therefore, the-no-xft suffix is added, compilation successful. If you do not want to add this suffix, copy the/qt-2.3.7/src/3 rdparty/FreeType/include/FreeType folder to the/qt-x11-2.3.2/lib directory.
Make-C/public/qt-x11-2.3.2/tools/qvfb in the youlong document is such make-C tools/qvfb after the test found that such compilation can not pass, only the absolute path can be entered.
Based on the developer's development environment, you can also add other parameters to configure parameters, such as-no-OpenGL or-no-xft. You can type. /configure-help to get some help information.
According to my understanding, there is no need. /configure after adding too many parameters, because the qt-x11-2.3.2 and qt-2.3.7 is not much difference, the purpose of the qt-x11-2.3.2 compilation is to generate the designer and UIC and qvfb, although the qt-2.3.7 can also generate qvfb and designer, however, considering the principle of backward compatibility, the 2.3.7 library of the program designed with the designer generated by 2.3.2 is certainly supported.
If the QT/embedded application is developed on the UNIX platform, it can be deployed on the developed machine.
It runs in an independent console or virtual buffer frame mode. For the latter, there is actually an X11
The application virtualizes a buffer frame. By specifying the width, height, and color depth of the display device, it is virtualized.
The buffer frame is consistent with that of the physical Display Device on each pixel. In this way, each time you debug an application, the developer
You do not always need to refresh the flash storage space of embedded devices to accelerate the compilation, linking, and running cycle of applications.
The only purpose of compiling QT/X11 is to provide UIC (User Interface compiler) and framebuffer device simulator qvfb based on X Windows system for compiling QTE. Of course, if you already have these two tools, compile QT/X11.
Because we need the execution file "UIC ".
UIC is used to convert. UI files to. h and. cpp files.
UIC is a file for x86
To run the virtual buffer frame tool of QT, run the command: qvfb & (Press ENTER) in graph mode of Linux)
When the QT embedded application needs to output the display result to the virtual buffer frame, we can run
Program, add the-qws option after the program name. Example: $>./Hello-qws
3.Install QT/embedded2.3.7
Run the following command on the terminal:
Tar zxf qt-embedded-2.3.7.tar.gz
CD/home/software/x86-qt/qt-2.3.7
Export qtedir =/home/software/x86-qt/qt-2.3.7
Export Path = $ qtedir/bin: $ path
Export LD_LIBRARY_PATH = $ qtedir/bin: $ LD_LIBRARY_PATH
Export qtdir = $ pwd
CP ../qconfig-local.h/home/software/x86-qt/qt-2.3.7/src/tools
Echo Yes |. /configure-platform linux-x86-g + +-shared-GIF-Sm-thread-system-zlib-system-libpng-system-libmng-system-JPEG-no-xft-qconfig local-depths 4,8, 16, 32
Make
CP $ qt2dir/bin/UIC $ qtedir/bin
CD ..
CP $ qpedir/src/QT/qconfig-local.h src/tools/This sentence may prompt that the file cannot be found because the qconfig-local.h is not in the/src/Qt directory, there is no such directory, there is a qconfig-local.h configuration file in the source code provided by youlong, copy it to the qt-2.3.7/src/tools. Qconfig-local.h is the configuration file for your own Development Board, mainly supports touch screen. You do not need a touch screen or a line on x86.
If you do not have this file, you do not need to use the CP line. /configure-qconfig local-qvfb-depths, 16, 32 changed. /configure-qconfig-qvfb-depths, 8, 16, 32.
The above command./configure-qconfig-qvfb-depths, 16, 32 specifiesQtThe embedded development kit generates the virtual buffer frame tool qvfb and supports the display color depth of 4, 8, 16, and 32 bits. You can also add-system-JPEG and GIF In the configure parameterQtThe/embedded platform supports JPEG and GIF images.
The command make sub-Src specifies to compile the development kit in simplified mode, that is, someQtClass is not compiled.QtThe embedded development kit has five compilation range options that can be controlledQtThe size of the generated library file, but some ofQtTheQtCannot find the link in the library. Run the./configure-HELP command to view the specific usage of the compilation options.
After QT/E is compiled, several library files are generated. The library files compiled under x86 support application debugging under x86. The library file is in the/lib directory.
4. Compile qpe to install qtopia
CD qtopia-1.7.x
Export qtdir = $ qtedir
Export qpedir = $ pwd
Export Path = $ qpedir/bin: $ path
CD SRC
./Configure
Make
CD ../..
After completing these steps, you should see the write results, allow qvfb &, and then allow qpe. If you see the qpe desktop, congratulations, you have succeeded.
So far, the installation of the QT/embedded for x86 development environment is complete.
**************************************** ************
Note: For cross-compilation QTE, you only needLinux-x86-g ++ChangeLinux-arm-G ++And don't need to compile the qt-x11-2.3.2,
Well, with the previous Foundation, we can easily develop the environment under high arm.
1. Compile QT/E ( Arm)
Mkdir QT-arm;
Cd qt-arm // (remind you) create a directory dedicated to arm to avoid mixing with the previous
Tar xfz QT-Embedded-2.3.7.tar.gz
CD QT-2.3.7
Export qtdir = $ pwd
Export qtedir = $ qtdir
CP/Your DIR/qconfig-Local. H./src/tools // This is a configured compilation option File
Make clean // clean up first
./Configure-xplatform Linux-Arm-G ++-Shared-Debug-Qconfig local-qvfb-Depths, 8, 16, 32
Make sub-SRC
CD ..
The size of the library file libqte. so.2.3.7 after compilation is 20.5 mb. If you use./configure-xplatform Linux-Arm-G ++-qconfig local-The database file obtained by depths 5.6, is MB.
Some friends reported that the library generated by QT is too large because-Debug is added. By default, it is not added. This sentence indicates that the generated library contains debugging information, debugging information occupies a lot of space.
OK, so that the QTE library of ARM is created,
(Note,ArmCross-Compiler3.3.2The above).
Store the library file in the/lib directory and generate a library for the ARM processor. It will be burned into the board in the future.
2. Compile qtopia For Arm
CD qtopia-1.7.x
Export qtdir = $ qtedir // make requires UIC files in the qtedir/bin directory
Export qpedir = $ pwd
Export Path = $ qpedir/bin: $ path
Qembed-images $ qpedir/pics/inline/*. *> $ qpedir/src/libraries/qtopia/inlinepics_p.h
// Create your own icon file. You can skip this step without adding your own icons. // This is also a tool for qt3.
CD SRC
./Configure-platform Linux-Arm-G ++
Make
CD ..
QtAnd QT designer
After QT/embedded and qtopia are installed according to the preceding steps, you can run these programs.
Run the virtual simulation window of QT: in the graphic mode of Linux, run the command qvfb &; qtopia, which is just a program developed using QT/Embedded. Run the command in the graphic mode:
Export qtdir = $ qtedir,
Qpe &;
In this way, the qtopia program runs on qvfb, that is, the virtual simulation window of QT.
QT/Embedded is a development tool developed for Embedded Linux. QT encapsulates some common classes and their names start with Q, such as qstring and qdialog. This section describes how to use QT designer to design components and generate corresponding code.
In QT, components are divided into complexes, primitive bodies, and accessories. In QT, components are composed of abstract classes, complex component classes, and classes that manage component ry.
There are three main base classes in QT: qobject, qapplication, and qwidget.
Programming in QT, communication between objects using signal and slot is the main feature of QT. It is similar to the Message Mechanism in windows, but the signal and slot mechanisms actually implement a message encapsulation. When the object state changes, it sends a signal to notify all slots to accept signal. Although it does not know which functions are slots, the slot does not know which signal can receive them at the beginning. The relationship between signal and slot is not one-to-one. One signal can be sent to multiple slots, and the slot can also receive multiple signal. Slot is no different from other member functions except for being able to receive signal. This mechanism is more flexible than using callback functions, but it will slow down the program running speed. However, in the face of high-speed CPU, this loss is insignificant, and it can ensure the simplicity and flexibility of the program, which is very convenient.
In QT components, common member variables and member functions are defined, and all signal and slots related to the component are also defined.
The simplest way to combine components is to use QT designer. First, start QT designer. in Linux Command mode, type the following command (Suppose QT is installed in/usr/local ):
CD qt-2.3.2/bin
./Designer
In this way, you can start a interface similar to Delphi in windows.
Then, create a new qframe and drag the components You Need To the frame. I believe many people have had this experience and I will not describe it in detail here. When the disk is saved, the new component is saved as a file with the extension. UI. Assume that the file name is test. UI. You can use VI test. UI to view the file. It is a text written in XML. The test. UI is used to generate test. h and test. cpp. You can also see a UIC tool in this directory. QT is used to generate the. h and. cpp files of the UI file. In terminal mode, type the following command:
./UIC-O test. h test. UI
./UIC-O test. H-I test. cpp test. UI
Test. h and test. cpp are generated. This is a class. Of course, this is just something on the surface. You also need to add the corresponding signal and slot in the code to complete the required operations. It is worth noting that it is best to use the UIC of the corresponding version to generate code for the UI generated by the corresponding version. If you use the UI generated by the designer of QT 3.1.2 and the UIC of QT 2.3.2 to generate code, the generated code will be some empty functions.
In the general development process, a class generated through this UI is usually called base in QT. The above example is testbase, and then a new class is created, to inherit the base. It is usually called the implementation class impl, such as testimpl. Define the required member functions, signal, and slot in this implementation class, because the UI may need to be changed frequently. In this case, you only need to modify the UI in the designer, instead of ignoring these member functions, signal, and slot.
Makefile is required to compile a QT program. In QT, a dedicated makefile generation tool is provided, that is, tmake. To use tmake, you need to write a. Pro File Based on the program .. The Pro file is very simple and has a fixed format. The following is an example:
Template = app
Config = qtopia warn_on release
Moc_dir = TMP
Objects_dir = TMP
Headers = fcrs. h/
Structs. h/
Globalfunc. h/
Globalvars. h/
Testimpl. h
Sources = Main. CPP/
Globalfunc. CPP/
Globalvars. CPP/
Testimpl. cpp
Interfaces = test. UI/
Target = fcrs
After the. Pro file is generated, type the following command in the terminal:
Tmake-O makefile test. Pro
A makefile is automatically generated. You can use this makefile to compile the program.