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  · 

Styling

Qt's built-in widgets use the QStyle class to perform nearly all of their drawing. QStyle is an abstract base class that encapsulates the look and feel of a GUI, and can be used to make the widgets look exactly like the equivalent native widgets or to give the widgets a custom look.

Qt provides a set of QStyle subclasses that emulate the native look of the different platforms supported by Qt (QWindowsStyle, QMacStyle, QMotifStyle, etc.). These styles are built into the QtGui library, other styles can be made available using Qt's plugin mechansim.

Most functions for drawing style elements take four arguments:

  • an enum value specifying which graphical element to draw
  • a QStyleOption object specifying how and where to render that element
  • a QPainter object that should be used to draw the element
  • a QWidget object on which the drawing is performed (optional)

The style gets all the information it needs to render the graphical element from the QStyleOption class. The widget is passed as the last argument in case the style needs it to perform special effects (such as animated default buttons on Mac OS X), but it isn't mandatory. In fact, QStyle can be used to draw on any paint device (not just widgets), in which case the widget argument is a zero pointer.

The paint system also provides the QStylePainter class inheriting from QPainter. QStylePainter is a convenience class for drawing QStyle elements inside a widget, and extends QPainter with a set of high-level drawing functions implemented on top of QStyle's API. The advantage of using QStylePainter is that the parameter lists get considerably shorter.

QIcon

The QIcon class provides scalable icons in different modes and states.

QIcon can generate pixmaps reflecting an icon's state, mode and size. These pixmaps are generated from the set of pixmaps made available to the icon, and are used by Qt widgets to show an icon representing a particular action.

The rendering of a QIcon object is handled by the QIconEngine class. Each icon has a corresponding icon engine that is responsible for drawing the icon with a requested size, mode and state.

For more information about widget styling and appearance, see the Styles and Style Aware Widgets.

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