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  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QPaintDevice Class Reference
[QtGui module]

The QPaintDevice class is the base class of objects that can be painted. More...

#include <QPaintDevice>

Inherited by QGLPixelBuffer, QImage, QPicture, QPixmap, QPrinter, and QWidget.

Public Types

  • enum PaintDeviceMetric { PdmWidth, PdmHeight, PdmWidthMM, PdmHeightMM, ..., PdmPhysicalDpiY }

Public Functions

Protected Functions


Detailed Description

The QPaintDevice class is the base class of objects that can be painted.

A paint device is an abstraction of a two-dimensional space that can be drawn using a QPainter. Its default coordinate system has its origin located at the top-left position. X increases to the right and Y increases downwards. The unit is one pixel.

The drawing capabilities of QPaintDevice are currently implemented by the QWidget, QImage, QPixmap, QGLPixelBuffer, QPicture, and QPrinter subclasses.

To implement support for a new backend, you must derive from QPaintDevice and reimplement the virtual paintEngine() function to tell QPainter which paint engine should be used to draw on this particular device. Note that you also must create a corresponding paint engine to be able to draw on the device, i.e derive from QPaintEngine and reimplement its virtual functions.

Warning: Qt requires that a QApplication object exists before any paint devices can be created. Paint devices access window system resources, and these resources are not initialized before an application object is created.

The QPaintDevice class provides several functions returning the various device metrics: The depth() function returns its bit depth (number of bit planes). The height() function returns its height in default coordinate system units (e.g. pixels for QPixmap and QWidget) while heightMM() returns the height of the device in millimeters. Similiarily, the width() and widthMM() functions return the width of the device in default coordinate system units and in millimeters, respectively. Alternatively, the protected metric() function can be used to retrieve the metric information by specifying the desired PaintDeviceMetric as argument.

The logicalDpiX() and logicalDpiY() functions return the horizontal and vertical resolution of the device in dots per inch. The physicalDpiX() and physicalDpiY() functions also return the resolution of the device in dots per inch, but note that if the logical and vertical resolution differ, the corresponding QPaintEngine must handle the mapping. Finally, the numColors() function returns the number of different colors available for the paint device.

See also QPaintEngine, QPainter, The Coordinate System, and The Paint System.


Member Type Documentation

enum QPaintDevice::PaintDeviceMetric

Describes the various metrics of a paint device.

ConstantValueDescription
QPaintDevice::PdmWidth1The width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). See also width().
QPaintDevice::PdmHeight2The height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). See also height().
QPaintDevice::PdmWidthMM3The width of the paint device in millimeters. See also widthMM().
QPaintDevice::PdmHeightMM4The height of the paint device in millimeters. See also heightMM().
QPaintDevice::PdmNumColors5The number of different colors available for the paint device. See also numColors().
QPaintDevice::PdmDepth6The bit depth (number of bit planes) of the paint device. See also depth().
QPaintDevice::PdmDpiX7The horizontal resolution of the device in dots per inch. See also logicalDpiX().
QPaintDevice::PdmDpiY8The vertical resolution of the device in dots per inch. See also logicalDpiY().
QPaintDevice::PdmPhysicalDpiX9The horizontal resolution of the device in dots per inch. See also physicalDpiX().
QPaintDevice::PdmPhysicalDpiY10The vertical resolution of the device in dots per inch. See also physicalDpiY().

See also metric().


Member Function Documentation

QPaintDevice::QPaintDevice ()   [protected]

Constructs a paint device. This constructor can be invoked only from subclasses of QPaintDevice.

QPaintDevice::~QPaintDevice ()   [virtual]

Destroys the paint device and frees window system resources.

int QPaintDevice::depth () const

Returns the bit depth (number of bit planes) of the paint device.

int QPaintDevice::height () const

Returns the height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).

See also heightMM().

int QPaintDevice::heightMM () const

Returns the height of the paint device in millimeters.

See also height().

int QPaintDevice::logicalDpiX () const

Returns the horizontal resolution of the device in dots per inch, which is used when computing font sizes. For X11, this is usually the same as could be computed from widthMM(), but it varies on Windows.

Note that if the logicalDpiX() doesn't equal the physicalDpiX(), the corresponding QPaintEngine must handle the resolution mapping.

See also logicalDpiY() and physicalDpiX().

int QPaintDevice::logicalDpiY () const

Returns the vertical resolution of the device in dots per inch, which is used when computing font sizes. For X11, this is usually the same as could be computed from heightMM(), but it varies on Windows.

Note that if the logicalDpiY() doesn't equal the physicalDpiY(), the corresponding QPaintEngine must handle the resolution mapping.

See also logicalDpiX() and physicalDpiY().

int QPaintDevice::metric ( PaintDeviceMetric metric ) const   [virtual protected]

Returns the metric information for the given paint device metric.

See also PaintDeviceMetric.

int QPaintDevice::numColors () const

Returns the number of different colors available for the paint device. Since this value is an int, it will not be sufficient to represent the number of colors on 32 bit displays, in this case INT_MAX is returned instead.

QPaintEngine * QPaintDevice::paintEngine () const   [pure virtual]

Returns a pointer to the paint engine used for drawing on the device.

bool QPaintDevice::paintingActive () const

Returns true if the device is currently being painted on, i.e. someone has called QPainter::begin() but not yet called QPainter::end() for this device; otherwise returns false.

See also QPainter::isActive().

int QPaintDevice::physicalDpiX () const

Returns the horizontal resolution of the device in dots per inch.

Note that if the physicalDpiX() doesn't equal the logicalDpiX(), the corresponding QPaintEngine must handle the resolution mapping.

See also physicalDpiY() and logicalDpiX().

int QPaintDevice::physicalDpiY () const

Returns the horizontal resolution of the device in dots per inch.

Note that if the physicalDpiY() doesn't equal the logicalDpiY(), the corresponding QPaintEngine must handle the resolution mapping.

See also physicalDpiX() and logicalDpiY().

int QPaintDevice::width () const

Returns the width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).

See also widthMM().

int QPaintDevice::widthMM () const

Returns the width of the paint device in millimeters.

See also width().

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 103
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 56
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 97
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 32
  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 » 231
  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. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 103
  7. 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
Page suivante

Le Qt Developer Network au hasard

Logo

Applications mobiles modernes avec Qt et QML

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.1
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