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  · 

QStylePainter Class Reference
[QtGui module]

The QStylePainter class is a convenience class for drawing QStyle elements inside a widget. More...

 #include <QStylePainter>

Inherits QPainter.

Public Functions

  • QStylePainter ( QWidget * widget )
  • QStylePainter ( QPaintDevice * pd, QWidget * widget )
  • bool begin ( QWidget * widget )
  • bool begin ( QPaintDevice * pd, QWidget * widget )
  • void drawComplexControl ( QStyle::ComplexControl cc, const QStyleOptionComplex & option )
  • void drawControl ( QStyle::ControlElement ce, const QStyleOption & option )
  • void drawItemPixmap ( const QRect & rect, int flags, const QPixmap & pixmap )
  • void drawItemText ( const QRect & rect, int flags, const QPalette & pal, bool enabled, const QString & text, QPalette::ColorRole textRole = QPalette::NoRole )
  • void drawPrimitive ( QStyle::PrimitiveElement pe, const QStyleOption & option )
  • QStyle * style () const
  • 166 public functions inherited from QPainter

Additional Inherited Members

  • 3 static public members inherited from QPainter

Detailed Description

The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.

QStylePainter extends QPainter with a set of high-level draw...() functions implemented on top of QStyle's API. The advantage of using QStylePainter is that the parameter lists get considerably shorter. Whereas a QStyle object must be able to draw on any widget using any painter (because the application normally has one QStyle object shared by all widget), a QStylePainter is initialized with a widget, eliminating the need to specify the QWidget, the QPainter, and the QStyle for every function call.

Example using QStyle directly:

 void MyWidget::paintEvent(QPaintEvent * /* event */)
 {
     QPainter painter(this);

     QStyleOptionFocusRect option;
     option.initFrom(this);
     option.backgroundColor = palette().color(QPalette::Background);

     style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this);
 }

Example using QStylePainter:

 void MyWidget::paintEvent(QPaintEvent * /* event */)
 {
     QStylePainter painter(this);

     QStyleOptionFocusRect option;
     option.initFrom(this);
     option.backgroundColor = palette().color(QPalette::Background);

     painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
 }

See also QStyle and QStyleOption.


Member Function Documentation

QStylePainter::QStylePainter ()

Constructs a QStylePainter.

QStylePainter::QStylePainter ( QWidget * widget )

Construct a QStylePainter using widget widget for its paint device.

QStylePainter::QStylePainter ( QPaintDevice * pd, QWidget * widget )

Construct a QStylePainter using pd for its paint device, and attributes from widget.

bool QStylePainter::begin ( QWidget * widget )

Begin painting operations on the specified widget. Returns true if the painter is ready to use; otherwise returns false.

This is automatically called by the constructor that takes a QWidget.

bool QStylePainter::begin ( QPaintDevice * pd, QWidget * widget )

This is an overloaded member function, provided for convenience.

Begin painting operations on paint device pd as if it was widget.

This is automatically called by the constructor that takes a QPaintDevice and a QWidget.

void QStylePainter::drawComplexControl ( QStyle::ComplexControl cc, const QStyleOptionComplex & option )

Use the widget's style to draw a complex control cc specified by the QStyleOptionComplex option.

See also QStyle::drawComplexControl().

void QStylePainter::drawControl ( QStyle::ControlElement ce, const QStyleOption & option )

Use the widget's style to draw a control element ce specified by QStyleOption option.

See also QStyle::drawControl().

void QStylePainter::drawItemPixmap ( const QRect & rect, int flags, const QPixmap & pixmap )

Draws the pixmap in rectangle rect. The pixmap is aligned according to flags.

See also QStyle::drawItemPixmap() and Qt::Alignment.

void QStylePainter::drawItemText ( const QRect & rect, int flags, const QPalette & pal, bool enabled, const QString & text, QPalette::ColorRole textRole = QPalette::NoRole )

Draws the text in rectangle rect and palette pal. The text is aligned and wrapped according to flags.

The pen color is specified with textRole. The enabled bool indicates whether or not the item is enabled; when reimplementing this bool should influence how the item is drawn.

See also QStyle::drawItemText() and Qt::Alignment.

void QStylePainter::drawPrimitive ( QStyle::PrimitiveElement pe, const QStyleOption & option )

Use the widget's style to draw a primitive element pe specified by QStyleOption option.

See also QStyle::drawPrimitive().

QStyle * QStylePainter::style () const

Return the current style used by the QStylePainter.

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 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. 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
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Comment fermer une application

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