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  · 

QPaintEngine Class Reference
[QtGui module]

The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a given platform. More...

#include <QPaintEngine>

Public Types

Public Functions

  • QPaintEngine ( PaintEngineFeatures caps = 0 )
  • virtual ~QPaintEngine ()
  • virtual bool begin ( QPaintDevice * pdev ) = 0
  • virtual void drawEllipse ( const QRectF & rect )
  • virtual void drawEllipse ( const QRect & rect )
  • virtual void drawImage ( const QRectF & rectangle, const QImage & image, const QRectF & sr, Qt::ImageConversionFlags flags = Qt::AutoColor )
  • virtual void drawLines ( const QLineF * lines, int lineCount )
  • virtual void drawLines ( const QLine * lines, int lineCount )
  • virtual void drawPath ( const QPainterPath & path )
  • virtual void drawPixmap ( const QRectF & r, const QPixmap & pm, const QRectF & sr ) = 0
  • virtual void drawPoints ( const QPointF * points, int pointCount )
  • virtual void drawPoints ( const QPoint * points, int pointCount )
  • virtual void drawPolygon ( const QPointF * points, int pointCount, PolygonDrawMode mode )
  • virtual void drawPolygon ( const QPoint * points, int pointCount, PolygonDrawMode mode )
  • virtual void drawRects ( const QRectF * rects, int rectCount )
  • virtual void drawRects ( const QRect * rects, int rectCount )
  • virtual void drawTextItem ( const QPointF & p, const QTextItem & textItem )
  • virtual void drawTiledPixmap ( const QRectF & rect, const QPixmap & pixmap, const QPointF & p )
  • virtual bool end () = 0
  • bool hasFeature ( PaintEngineFeatures feature ) const
  • bool isActive () const
  • QPaintDevice * paintDevice () const
  • QPainter * painter () const
  • void setActive ( bool state )
  • virtual Type type () const = 0

Detailed Description

The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a given platform.

Qt 4.0 provides several premade implementations of QPaintEngine for the different painter backends we support. We provide one paint engine for each window system and painting framework we support. This includes X11 on Unix/Linux and CoreGraphics on Mac OS X. In addition we provide QPaintEngine implementations for OpenGL (accessible through QGLWidget) and PostScript (accessible through QPSPrinter on X11). Additionally there is a raster-based paint engine that is a fallback for when an engine does not support a certain capability.

If one wants to use QPainter to draw to a different backend, such as PDF, one must subclass QPaintEngine and reimplement all its virtual functions. The QPaintEngine implementation is then made available by subclassing QPaintDevice and reimplementing the virtual function QPaintDevice::paintEngine().

QPaintEngine is created and owned by the QPaintDevice that created it.

The big advantage of the QPaintEngine approach opposed to Qt 3's QPainter/QPaintDevice::cmd() approach is that it is now possible to adapt to multiple technologies on each platform and take advantage of each to the fullest.

See also QPainter and QPaintDevice::paintEngine().


Member Type Documentation

enum QPaintEngine::PaintEngineFeature
flags QPaintEngine::PaintEngineFeatures

This enum is used to describe the features or capabilities that the paint engine has. If a feature is not supported by the engine, QPainter will do a best effort to emulate that feature through other means and pass on an alpha blended QImage to the engine with the emulated results. Some features cannot be emulated: AlphaBlend and PorterDuff.

ConstantValueDescription
QPaintEngine::PrimitiveTransform0x00000001The engine has support for transforming drawing primitives.
QPaintEngine::PatternTransform0x00000002The engine has support for transforming brush patterns.
QPaintEngine::PixmapTransform0x00000004The engine can transform pixmaps, including rotation and shearing.
QPaintEngine::PatternBrush0x00000008The engine is capable of rendering brushes with the brush patterns specified in Qt::BrushStyle.
QPaintEngine::LinearGradientFill0x00000010The engine supports linear gradient fills.
QPaintEngine::RadialGradientFill0x00000020The engine supports radial gradient fills.
QPaintEngine::ConicalGradientFill0x00000040The engine supports conical gradient fills.
QPaintEngine::AlphaBlend0x00000080The engine can alpha blend primitives.
QPaintEngine::PorterDuff0x00000100The engine supports Porter-Duff operations
QPaintEngine::PainterPaths0x00000200The engine has path support.
QPaintEngine::Antialiasing0x00000400The engine can use antialising to improve the appearance of rendered primitives.
QPaintEngine::BrushStroke0x00000800 
QPaintEngine::PaintOutsidePaintEvent0x20000000The engine is capable of painting outside of paint events.
QPaintEngine::AllFeatures0xffffffff 

The PaintEngineFeatures type is a typedef for QFlags<PaintEngineFeature>. It stores an OR combination of PaintEngineFeature values.

enum QPaintEngine::PolygonDrawMode

ConstantValueDescription
QPaintEngine::OddEvenMode0The polygon should be drawn using OddEven fill rule.
QPaintEngine::WindingMode1The polygon should be drawn using Winding fill rule.
QPaintEngine::ConvexMode2The polygon is a convex polygon and can be drawn using specialized algorithms where available.
QPaintEngine::PolylineMode3Only the outline of the polygon should be drawn.

enum QPaintEngine::Type

ConstantValueDescription
QPaintEngine::X110 
QPaintEngine::Windows1 
QPaintEngine::MacPrinter4 
QPaintEngine::CoreGraphics3Mac OS X's Quartz2D (CoreGraphics)
QPaintEngine::QuickDraw2Mac OS X's older QuickDraw-based painting
QPaintEngine::QWindowSystem5Qt/Embedded
QPaintEngine::PostScript6 
QPaintEngine::OpenGL7 
QPaintEngine::Picture8QPicture format
QPaintEngine::SVG9Scalable Vector Graphics XML format
QPaintEngine::Raster10 
QPaintEngine::User50First user type ID
QPaintEngine::MaxUser100Last user type ID

Member Function Documentation

QPaintEngine::QPaintEngine ( PaintEngineFeatures caps = 0 )

Creates a paint engine with the featureset specified by caps.

QPaintEngine::~QPaintEngine ()   [virtual]

Destroys the paint engine.

bool QPaintEngine::begin ( QPaintDevice * pdev )   [pure virtual]

Reimplement this function to initialise your paint engine when painting is to start on the paint device pdev. Return true if the initialization was successful; otherwise return false.

See also end() and isActive().

void QPaintEngine::drawEllipse ( const QRectF & rect )   [virtual]

Reimplement this function to draw the largest ellipse that can be contained within rectangle rect.

The default implementation calls drawPolygon().

void QPaintEngine::drawEllipse ( const QRect & rect )   [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

The default implementation of this function calls the floating point version of this function

void QPaintEngine::drawImage ( const QRectF & rectangle, const QImage & image, const QRectF & sr, Qt::ImageConversionFlags flags = Qt::AutoColor )   [virtual]

Reimplement this function to draw the part of the image specified by the sr rectangle in the given rectangle using the given conversion flags flags, to convert it to a pixmap.

void QPaintEngine::drawLines ( const QLineF * lines, int lineCount )   [virtual]

The default implementation splits the list of lines in lines into lineCount separate calls to drawPath() or drawPolygon() depending on the feature set of the paint engine.

void QPaintEngine::drawLines ( const QLine * lines, int lineCount )   [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

The default implementation converts the first lineCount lines in lines to a QLineF and calls the floating point version of this function.

void QPaintEngine::drawPath ( const QPainterPath & path )   [virtual]

The default implementation ignores the path and does nothing.

void QPaintEngine::drawPixmap ( const QRectF & r, const QPixmap & pm, const QRectF & sr )   [pure virtual]

Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r.

void QPaintEngine::drawPoints ( const QPointF * points, int pointCount )   [virtual]

Draws the first pointCount points in the buffer points

void QPaintEngine::drawPoints ( const QPoint * points, int pointCount )   [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Draws the first pointCount points in the buffer points

The default implementation converts the first pointCount QPoints in points to QPointFs and calls the floating point version of drawPoints.

void QPaintEngine::drawPolygon ( const QPointF * points, int pointCount, PolygonDrawMode mode )   [virtual]

Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode.

The default implementation of this function will try to use drawPath if the engine supports the feature QPaintEngine::PainterPaths or try the float based drawPolygon() implementation if not.

void QPaintEngine::drawPolygon ( const QPoint * points, int pointCount, PolygonDrawMode mode )   [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode.

The default implementation of this function will try to use drawPath() if the engine supports the feature QPaintEngine::PainterPaths or try the int based drawPolygon() implementation if not.

void QPaintEngine::drawRects ( const QRectF * rects, int rectCount )   [virtual]

Draws the first rectCount rectangles in the buffer rects. The default implementation of this function calls drawPath() or drawPolygon() depending on the feature set of the paint engine.

void QPaintEngine::drawRects ( const QRect * rects, int rectCount )   [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF and calls the floating point version of this function.

void QPaintEngine::drawTextItem ( const QPointF & p, const QTextItem & textItem )   [virtual]

This function draws the text item textItem at position p. The default implementation of this function converts the text to a QPainterPath and paints the resulting path.

void QPaintEngine::drawTiledPixmap ( const QRectF & rect, const QPixmap & pixmap, const QPointF & p )   [virtual]

Reimplement this function to draw the pixmap in the given rect, starting at the given p. The pixmap will be drawn repeatedly until the rect is filled.

bool QPaintEngine::end ()   [pure virtual]

Reimplement this function to finish painting on the current paint device. Return true if painting was finished successfully; otherwise return false.

See also begin() and isActive().

bool QPaintEngine::hasFeature ( PaintEngineFeatures feature ) const

Returns true if the paint engine supports the specified feature; otherwise returns false.

bool QPaintEngine::isActive () const

Returns true if the paint engine is actively drawing; otherwise returns false.

See also setActive().

QPaintDevice * QPaintEngine::paintDevice () const

Returns the engine that this engine is painting on, if painting is active; otherwise returns 0.

QPainter * QPaintEngine::painter () const

Returns the paint engine's painter.

void QPaintEngine::setActive ( bool state )

Sets the active state of the paint engine to state.

See also isActive().

Type QPaintEngine::type () const   [pure virtual]

Reimplement this function to return the paint engine Type.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 69
  2. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  3. Une nouvelle ère d'IHM 3D pour les automobiles, un concept proposé par Digia et implémenté avec Qt 3
  4. Qt Creator 2.5 est sorti en beta, l'EDI supporte maintenant plus de fonctionnalités de C++11 2
  5. Vingt sociétés montrent leurs décodeurs basés sur Qt au IPTV World Forum, en en exploitant diverses facettes (déclaratif, Web, widgets) 0
  6. PySide devient un add-on Qt et rejoint le Qt Project et le modèle d'open gouvernance 1
  7. Thread travailleur avec Qt en utilisant les signaux et les slots, un article de Christophe Dumez traduit par Thibaut Cuvelier 1
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 101
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 51
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 69
  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 Quarterly au hasard

Logo

La reconnaissance des gestes de souris

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. 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.0
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