Qt/Embedded Whitepaper
Trolltech
www.trolltech.com
Abstract
This whitepaper describes the Qt/Embedded C++ toolkit for GUI and application develop-
ment on embedded devices. It runs on any device supported by Linux and a C++ compiler.
Qt/Embeddedprovidesthe entire standardQt API and can compile out unused features to min-
imize its memory footprint. Qt/Embedded provides its own windowing system which is far
more compact than Xlib and the X Window System that it replaces. Qt/Embedded applications
can be developed on familiar desktop systems, e.g. Windows and Unix, and with standard tools.
It is provided with all the Qt tools including
Qt Designer
for visual form design, and with tools
specifically tailored to the embedded environment.
The Sharp Zaurus PDA using Qt/Embedded
ii
Qt/Embedded Whitepaper
Trolltech
www.trolltech.com
Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2. System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3. Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1. Windowing System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2. Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.3. Input Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.4. Input Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.5. Screen Acceleration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4. Development Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.1. Qt’s Supporting Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5. Signals and Slots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5.1. A Signals and Slots Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.2. Meta Object Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6. Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.1. A ‘Hello’ Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.2. Common Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.3. Canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
6.4. Custom Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
6.5. Main Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.6. Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.7. Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.8. Balloon Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.9. Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
7. Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7.1. Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7.2.
Qt Designer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.3. Built-in Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
8. Look and Feel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
8.1. Widget Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
8.2. Window Decorations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
9. Internationalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
9.1. Unicode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
9.2. Translating Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
9.3. Qt Linguist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
10. Non-Graphical Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
10.1. Collection Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
10.2. Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
10.3. Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
10.4. Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
10.5. Multi-Threading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
11. Qt/Embedded in the Wider World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2
1. Introduction
Qt/Embedded is a C++ toolkit for GUI and application development for embedded devices. It
runsonavariety of processors,usually with Embedded Linux. Qt/Embedded applicationswrite
directly to the frame-buffer, eliminating the need for the X Window System. In addition to the
class library, Qt/Embedded includes several tools to speed and ease development. Applications
can be developed with familiar programming environments on Windows and Unix, using the
standard Qt API.
Qt/Embedded is a port of the Qt C++ API for embedded devices. It provides the same API and
tools as the Qt/X11, Qt/Windows and Qt/Mac versions. Qt/Embedded also includes classes
and tools to specifically support embedded development.
The Qt C++ toolkit upon which Qt/Embedded is built has been at the heart of commercial
applications since 1995. Qt is used by enterprises as diverse as AT&T, IBM, NASA, Sharp and
Xerox, and by numerous smaller companies and organizations. Qt 3.0 retains the power and
ease of use of earlier versions and introduces many new classes. Qt’s classes are fully featured
to reduce developer workload, and provide consistent interfaces to speed learning. Qt is, and
always has been, fully object-oriented.
Qt provides a type-safe alternative to old fashioned callbacks, called signals and slots [p. 8],
that facilitates true component programming. Qt supplies a wide range of versatile widgets
[p. 11] that can easily be subclassed to create custom components, or combined to create custom
dialogs [p. 19]. Pre-defined dialogs for common tasks such as message boxes and wizards are
also provided.
Qt/Embedded has much smaller system requirements [p. 4], i.e. lower storage (Flash) and
memory (RAM) footprints, than embedded solutions based on the X Window System. It can
run on hardware that runs Linux, has a linearly addressable framebuffer, and supports a C++
compiler. And Qt/Embedded can be recompiled to exclude unused features to reduce its
memory footprint even further.
The architecture [p. 5] of Qt/Embedded includes its own windowing system [p. 6]. A variety of
input devices [p. 7] are supported.
Developers write code using their familiar development environments [p. 8].
Qt Designer
[p. 22]
can be used to visually design user interfaces using Qt’s layout [p. 19] system, which automat-
ically adapts to the available screen space. Developers can choose one of the pre-defined look
and feel [p. 24] styles or create their own unique styles. Unix users can run and test their appli-
cations on a pixel-perfect virtual frame-buffer.
Qt/Embedded also provides many non-graphical components [p. 28] for specialized tasks,
such as internationalization [p. 25], networking and database interaction.
Qt/Embedded is a mature, solid C++ toolkit, widely used all over the world [p. 30]. In addition
to Qt/Embedded’s many other commercial uses, it is the foundation of the Qtopia application
environment for small devices. Qt/Embedded makes application development a pleasure,
with its simple build system, visual form design and elegant API.
3
评论0