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  ·  Tous les espaces de nom  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QDirectPainter Class Reference
[QtGui module]

The QDirectPainter class provides direct access to the underlying hardware in Qt for Embedded Linux. More...

 #include <QDirectPainter>

Inherits QObject.

Public Types

  • enum SurfaceFlag { NonReserved, Reserved, ReservedSynchronous }

Public Functions

  • 29 public functions inherited from QObject

Static Public Members

  • 5 static public members inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 signal inherited from QObject
  • 7 protected functions inherited from QObject

Detailed Description

The QDirectPainter class provides direct access to the underlying hardware in Qt for Embedded Linux.

Note that this class is only available in Qt for Embedded Linux.

QDirectPainter allows a client application to reserve a region of the framebuffer and render directly onto the screen. There are two ways of using the QDirectPainter class: You can either reserve a region using the provided static functions, or you can instantiate an object and make use of its more dynamic API.

Dynamic Allocation

By instantiating a QDirectPainter object using the default QDirectPainter::NonReserved surface flag, the client application only gets some control over the reserved region, i.e., it can still render directly onto the screen but the allocated region may change (for example, if a window with a higher focus requests parts of the same region). The currently allocated region can be retrieved using the allocatedRegion() function, while the requestedRegion() function returns the originally reserved region.

Static Allocation

Using the static approach, the client application gets complete control over the reserved region, i.e., the affected region will never be modified by the screen driver.

To create a static region, pass the QDirectPainter::Reserved surface flag to the constructor. After the reserved region is reported through regionChanged(), the allocated region will not change, unless setRegion() is called.

If QDirectPainter::ReservedSynchronous is passed to the constructor, calls to setRegion() will block until the region is reserved, meaning that allocatedRegion() will be available immediately. Note that in the current version setRegion() will cause the application event loop to be entered, potentially causing reentrancy issues.

Rendering

To draw on a given region, the application must first get hold of a pointer to the framebuffer. In most cases, this pointer 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.

Depending on the hardware, it might be necessary to lock the framebuffer for exclusive use while writing to it. This is possible using the lock() and unlock() functions. Note that calling lock() will prevent all other applications from working until unlock() is called.

In addition, QDirectPainter provides several functions returning information about the framebuffer: the linestep() function returns the length (in bytes) of each scanline of the framebuffer while the screenDepth(), screenWidth() and screenHeight() function return the screen metrics.

See also QScreen, QWSEmbedWidget, and Qt for Embedded Linux Architecture.


Member Type Documentation

enum QDirectPainter::SurfaceFlag

This enum describes the behavior of the region reserved by this QDirectPainter object.

ConstantValueDescription
QDirectPainter::NonReserved0The allocated region may change, e.g., if a window with a higher focus requests parts of the same region. See also Dynamic Allocation.
QDirectPainter::Reserved1The allocated region will never change. See also Static Allocation.
QDirectPainter::ReservedSynchronous3The allocated region will never change and each function that changes the allocated region will be blocking.

See also reservedRegion() and allocatedRegion().


Member Function Documentation

QDirectPainter::QDirectPainter ( QObject * parent = 0, SurfaceFlag flag = NonReserved )

Constructs a QDirectPainter object with the given parent and surface flag.

QDirectPainter::~QDirectPainter ()

Destroys this QDirectPainter object, releasing the reserved region.

See also allocatedRegion().

QRegion QDirectPainter::allocatedRegion () const

Returns the currently reserved region.

Note that if the QDirectPainter::Reserved flag is set, the region returned by this function will always be equivalent to the region returned by the requestedRegion() function. Otherwise they might differ (see Dynamic Allocation for details).

This function was introduced in Qt 4.2.

See also requestedRegion() and geometry().

void QDirectPainter::endPainting ()

Call this function when you are done updating the screen. It will notify the hardware, if necessary, that your painting operations have ended.

This function was introduced in Qt 4.2.

void QDirectPainter::endPainting ( const QRegion & region )

This is an overloaded member function, provided for convenience.

This function will automatically call flush() to flush the region to the display before notifying the hardware, if necessary, that painting operations have ended.

This function was introduced in Qt 4.3.

void QDirectPainter::flush ( const QRegion & region )

Flushes the region onto the screen.

This function was introduced in Qt 4.3.

uchar * QDirectPainter::frameBuffer ()   [static]

Returns a pointer to the beginning of the display memory.

Note that it is the application's responsibility to limit itself to modifying only the reserved region.

Do not use this pointer if the current screen has subscreens, query the screen driver instead: 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.

See also requestedRegion(), allocatedRegion(), and linestep().

QRect QDirectPainter::geometry () const

Returns the bounding rectangle of the requested region.

This function was introduced in Qt 4.2.

See also setGeometry() and requestedRegion().

int QDirectPainter::linestep ()   [static]

Returns the length (in bytes) of each scanline of the framebuffer.

See also frameBuffer().

void QDirectPainter::lock ()   [static]

Locks access to the framebuffer.

Note that calling this function will prevent all other applications from updating the display until unlock() is called.

See also unlock().

void QDirectPainter::lower ()

Lowers the reserved region to the bottom of the widget stack.

After this call the reserved region will be visually behind (and therefore obscured by) any overlapping widgets.

This function was introduced in Qt 4.2.

See also raise() and requestedRegion().

void QDirectPainter::raise ()

Raises the reserved region to the top of the widget stack.

After this call the reserved region will be visually in front of any overlapping widgets.

This function was introduced in Qt 4.2.

See also lower() and requestedRegion().

void QDirectPainter::regionChanged ( const QRegion & newRegion )   [virtual]

This function is called when the allocated region changes.

This function is not called for region changes that happen while the startPainting() function is executing.

Note that the given region, newRegion, is not guaranteed to be correct at the time you access the display. To prevent reentrancy problems you should always call startPainting() before updating the display and then use allocatedRegion() to retrieve the correct region.

This function was introduced in Qt 4.2.

See also allocatedRegion(), startPainting(), and Dynamic Allocation.

QRegion QDirectPainter::requestedRegion () const

Returns the region requested by this QDirectPainter.

Note that if the QDirectPainter::Reserved flag is set, the region returned by this function will always be equivalent to the region returned by the allocatedRegion() function. Otherwise they might differ (see Dynamic Allocation for details).

This function was introduced in Qt 4.2.

See also geometry() and setRegion().

int QDirectPainter::screenDepth ()   [static]

Returns the bit depth of the display.

See also screenHeight() and screenWidth().

int QDirectPainter::screenHeight ()   [static]

Returns the height of the display in pixels.

See also screenWidth() and screenDepth().

int QDirectPainter::screenWidth ()   [static]

Returns the width of the display in pixels.

See also screenHeight() and screenDepth().

void QDirectPainter::setGeometry ( const QRect & rectangle )

Request to reserve the given rectangle of the framebuffer.

Note that the actually allocated region might differ from the requested one, e.g., if the given region overlaps with the region of another QDirectPainter object.

This function was introduced in Qt 4.2.

See also geometry(), allocatedRegion(), and setRegion().

void QDirectPainter::setRegion ( const QRegion & region )

Requests to reserve the given region of the framebuffer.

Note that the actually allocated region might differ from the requested one, e.g., if the given region overlaps with the region of another QDirectPainter object.

This function was introduced in Qt 4.2.

See also region(), requestedRegion(), allocatedRegion(), and Dynamic Allocation.

void QDirectPainter::startPainting ( bool lockDisplay = true )

Call this function before you start updating the pixels in the allocated region. The hardware will be notified, if necessary, that you are about to start painting operations.

Set lockDisplay if you want startPainting() and endPainting() to lock() and unlock() the display automatically.

Note that for a NonReserved direct painter, you must call allocatedRegion() after calling this function, since the allocated region is only guaranteed to be correct after this function has returned.

The regionChanged() function will not be called between startPainting() and endPainting().

This function was introduced in Qt 4.2.

See also endPainting() and flush().

void QDirectPainter::unlock ()   [static]

Warning: This function is not yet implemented.

Unlocks the lock on the framebuffer (set using the lock() function), allowing other applications to access the screen.

See also lock().

WId QDirectPainter::winId () const

Returns the window system identifier of the widget.

This function was introduced in Qt 4.2.

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 102
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 53
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 73
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 229
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
  7. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 101
Page suivante

Le Qt Developer Network au hasard

Logo

Combiner licence, à propos et fermer d'une autre manière

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. 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.4
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