Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

Qt for Embedded Linux Architecture

A Qt for Embedded Linux application requires a server application to be running, or to be the server application itself. Any Qt for Embedded Linux application can act as the server. When more than one application is running, the subsequent applications connect to the existing server application as clients.

The server and client processes have different responsibilities: The server process manages pointer handling, character input, and screen output. In addition, the server controls the appearance of the screen cursor and the screen saver. The client process performs all application specific operations.

The server application is represented by an instance of the QWSServer class, while the client applications are represented by instances of the QWSClient class. On each side, there are several classes performing the various operations.

All system generated events, including keyboard and mouse events, are passed to the server application which then propagates the event to the appropriate client.

When rendering, the default behavior is for each client to render its widgets into memory while the server is responsible for putting the contents of the memory onto the screen. But when the hardware is known and well defined, as is often the case with software for embedded devices, it may be useful for the clients to manipulate and control the underlying hardware directly. Qt for Embedded Linux provides two different approaches to achieve this behavior, see the graphics rendering section below for details.

Client/Server Communication

The running applications continuously alter the appearance of the screen by adding and removing widgets. The server maintains information about each top-level window in a corresponding QWSWindow object.

Whenever the server receives an event, it queries its stack of top-level windows to find the window containing the event's position. Each window can identify the client application that created it, and returns its ID to the server upon request. Finally, the server forwards the event, encapsulated by an instance of the QWSEvent class, to the appropriate client.

If an input method is installed, it is used as a filter between the server and the client application. Derive from the QWSInputMethod class to implement custom input methods, and use the server's setCurrentInputMethod() function to install it. In addition, it is possible to implement global, low-level filters on key events using the QWSServer::KeyboardFilter class; this can be used to implement things like advanced power management suspended from a button without having to filter for it in all applications.

UNIX Domain Socket

The server communicates with the client applications over the UNIX domain socket. You can retrieve direct access to all the events a client receives from the server, by reimplementing QApplication's qwsEventFilter() function.

The clients (and the server) communicate with each other using the QCopChannel class. QCOP is a many-to-many communication protocol for transferring messages on various channels. A channel is identified by a name, and anyone who wants to can listen to it. The QCOP protocol allows clients to communicate both within the same address space and between different processes.

Pointer Handling Layer

The mouse driver (represented by an instance of the QWSMouseHandler class) is loaded by the server application when it starts running, using Qt's plugin system.

A mouse driver receives mouse events from the device and encapsulates each event with an instance of the QWSEvent class which it then passes to the server.

Qt for Embedded Linux provides ready-made drivers for several mouse protocols, see the pointer handling documentation for details. Custom mouse drivers can be implemented by subclassing the QWSMouseHandler class and creating a mouse driver plugin. The default implementation of the QMouseDriverFactory class will automatically detect the plugin, loading the driver into the server application at runtime.

In addition to the generic mouse handler, Qt for Embedded Linux provides a calibrated mouse handler. Use the QWSCalibratedMouseHandler class as the base class when the system device does not have a fixed mapping between device and screen coordinates and/or produces noisy events, e.g. a touchscreen.

See also: Qt for Embedded Linux Pointer Handling and How to Create Qt Plugins.

Character Input Layer

The keyboard driver (represented by an instance of the QWSKeyboardHandler class) is loaded by the server application when it starts running, using Qt's plugin system.

A keyboard driver receives keyboard events from the device and encapsulates each event with an instance of the QWSEvent class which it then passes to the server.

Qt for Embedded Linux provides ready-made drivers for several keyboard protocols, see the character input documentation for details. Custom keyboard drivers can be implemented by subclassing the QWSKeyboardHandler class and creating a keyboard driver plugin. The default implementation of the QKbdDriverFactory class will automatically detect the plugin, loading the driver into the server application at run-time.

See also: Qt for Embedded Linux Character Input and How to Create Qt Plugins.

Graphics Rendering

The default behavior is for each client to render its widgets as well as its decorations into memory, while the server copies the memory content to the device's framebuffer.

Whenever a client receives an event that alters any of its widgets, the application updates the relevant parts of its memory buffer:

The decoration is loaded by the client application when it starts running (using Qt's plugin system), and can be customized by deriving from the QDecoration class and creating a decoration plugin. The default implementation of the QDecorationFactory class will automatically detect the plugin, loading the decoration into the application at runtime. Call the QApplication::qwsSetDecoration() function to actually apply the given decoration to an application.

Direct Painting
It is possible for the clients to manipulate and control the underlying hardware directly. There are two ways of achieving this: The first approach is to set the Qt::WA_PaintOnScreen window attribute for each widget, the other is to use the QDirectPainter class to reserve a region of the framebuffer.

By setting the Qt::WA_PaintOnScreen attribute, the application renders the widget directly onto the screen and the affected region will not be modified by the screen driver unless another window with a higher focus requests (parts of) the same region. Note that if you want to render all of an application's widgets directly on screen, it might be easier to set the QT_ONSCREEN_PAINT environment variable.

Using QDirectPainter, on the other hand, provides a complete control over the reserved region, i.e., the screen driver will never modify the given region.

To draw on a region reserved by a QDirectPainter instance, the application must get hold of a pointer to the framebuffer. In general, a pointer to the framebuffer can be retrieved using the QDirectPainter::frameBuffer() function. But note that if the current screen has subscreens, you must query the screen driver instead to identify the correct subscreen. A pointer to the current screen driver can always be retrieved using the static QScreen::instance() function. Then use QScreen's subScreenIndexAt() and subScreens() functions to access the correct subscreen, and the subscreen's base() function to retrieve a pointer to the framebuffer.

Note that Qt for Embedded Linux also provides the QWSEmbedWidget class, making it possible to embed the reserved region (i.e., the QDirectPainter object) in a regular widget.

Drawing on Screen

When a screen update is required, the server runs through all the top-level windows that intersect with the region that is about to be updated, and ensures that the associated clients have updated their memory buffer. Then the server uses the screen driver (represented by an instance of the QScreen class) to copy the content of the memory to the screen.

The screen driver is loaded by the server application when it starts running, using Qt's plugin system. Qt for Embedded Linux provides ready-made drivers for several screen protocols, see the display management documentation for details. Custom screen drivers can be implemented by subclassing the QScreen class and creating a screen driver plugin. The default implementation of the QScreenDriverFactory class will automatically detect the plugin, loading the driver into the server application at run-time.

To locate the relevant parts of memory, the driver is provided with the list of top-level windows that intersect with the given region. Associated with each of the top-level windows there is an instance of the QWSWindowSurface class representing the drawing area of the window. The driver uses these objects to retrieve pointers to the various memory blocks. Finally, the screen driver composes the surface images before copying the updated region to the framebuffer.

Accelerated Graphics
In Qt for Embedded Linux, painting is a pure software implementation, but (starting with Qt 4.2) it is possible to add an accelerated graphics driver to take advantage of available hardware resources.

The clients render each window onto a corresponding window surface object using Qt's paint system, and then store the surface in memory. The screen driver accesses the memory and composes the surface images before it copies them to the screen as explained above.

To add an accelerated graphics driver you must create a custom screen and implement a custom raster paint engine (Qt for Embedded Linux uses a raster-based paint engine to implement the painting operations). Then you must create a custom paint device that is aware of your paint engine, a custom window surface that knows about your paint device, and make your screen able to recognize your window surface.

See the accelerated graphics driver documentation for details.

See also: Qt for Embedded Linux Display Management and How to Create Qt Plugins.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 44
  2. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  5. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
Page suivante

Le blog Digia au hasard

Logo

Déploiement d'applications Qt Commercial sur les tablettes Windows 8

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.6
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web