Install and use the embedded tool Qt-general Linux technology-Linux programming and kernel information. For more information, see the following. 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.
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.
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.
Install Qt and Qtopia
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;
◆ Qt/Embedded 2.3.4 (Qtopia 1.6.0 is developed based on this development platform );
◆ Qt/Embedded 2.3.2 for X11;
◆ Qt 3.1.2 for X11.
You can download the free version of Qt/Embedded provided by Trolltech.
Qtopia Platform Installation involves the following steps:
1. Unpack Qtopia
Run the following command in Linux:
Tar xfz qtopia-source-1.6.0 (unpack)
Cd qtopia-source-1.6.0
Export QPEDIR = $ PWD (set environment variables)
Cd ..
You can also add-system-jpeg and gif to the configure parameters so that the Qtopia platform supports jpeg and gif images.
4. Install Qt/X11 2.3.2
Run the following command in Linux:
Tar xfz qt-x11-2.3.2-commercial.tar.gz
Cd qt-2.3.2
Export QTDIR = $ PWD
Export PATH = $ QTDIR/bin: $ PATH
Export LD_LIBRARY_PATH = $ QTDIR/lib: $ LD_LIBRARY_PATH
./Configure-no-opengl
Make
Make-C tools/qvfb
Mv tools/qvfb bin
Cp bin/uic $ QTEDIR/bin
Cd ..
Based on the developer's development environment, you can also add other parameters to configure 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:
Tar xfz qt-x11-commercial-3.1.x.tar.gz
Cd qt-x11-commercial-3.1.x
Export QTDIR = $ PWD
Export QT3DIR = $ QTDIR
Export PATH = $ QTDIR/bin: $ PATH
Export LD_LIBRARY_PATH = $ QTDIR/lib: $ LD_LIBRARY_PATH
./Configure-thread
Make
Cd ..
6. Install Qtopia
Run the following command in Linux:
Cd qtopia-source-1.6.x
Export QTDIR = $ QTEDIR
Export QPEDIR = $ PWD
Export PATH = $ QPEDIR/bin: $ PATH
Cd src
./Configure
Make
Cd ../..
7. Install Qtopia Desktop
Cd qtopia-source-1.6.x/src
Export QTDIR = $ QT3DIR
./Configure-qtopiadesktop
Make
Mv qtopiadesktop/bin/qtopiadesktop ../bin
Cd ..
Use of Qt and 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.
Create a new QFrame and drag the required components to the Frame. I believe many people have experienced this experience and 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:
In this case, 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:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service