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  ·  Classes  ·  Annotées  ·  Hiérarchie  ·  Fonctions  ·  Structure  · 

QPalette Class Reference


The QPalette class contains color groups for each widget state. More...

#include <qpalette.h>

List of all member functions.

Public Members

  • QPalette () 
  • QPalette ( const QColor & button ) (obsolete)
  • QPalette ( const QColor & button, const QColor & background ) 
  • QPalette ( const QColorGroup & active, const QColorGroup & disabled, const QColorGroup & inactive ) 
  • QPalette ( const QPalette & ) 
  • ~QPalette () 
  • QPalette& operator= ( const QPalette & ) 
  • enum ColorGroup { Normal, Disabled, Active, Inactive, NColorGroups }
  • const QColor& color ( ColorGroup, QColorGroup::ColorRole ) const
  • const QBrush& brush ( ColorGroup, QColorGroup::ColorRole ) const
  • void setColor ( ColorGroup, QColorGroup::ColorRole, const QColor & ) 
  • void setBrush ( ColorGroup, QColorGroup::ColorRole, const QBrush & ) 
  • void setColor ( QColorGroup::ColorRole, const QColor & ) 
  • void setBrush ( QColorGroup::ColorRole, const QBrush & ) 
  • QPalette copy () const
  • const QColorGroup& active () const
  • const QColorGroup& disabled () const
  • const QColorGroup& inactive () const
  • const QColorGroup& normal () const (obsolete)
  • void setActive ( const QColorGroup & ) 
  • void setDisabled ( const QColorGroup & ) 
  • void setInactive ( const QColorGroup & ) 
  • void setNormal ( const QColorGroup & ) (obsolete)
  • bool operator== ( const QPalette & p ) const
  • bool operator!= ( const QPalette & p ) const
  • bool isCopyOf ( const QPalette & ) 
  • int serialNumber () const

Related Functions

(Note that these are not member functions.)
  • QDataStream & operator>> (QDataStream & s, QPalette & p)
  • QDataStream & operator<< (QDataStream & s, const QPalette & p)

Detailed Description

The QPalette class contains color groups for each widget state.

A palette consists of three color groups: a active, a disabled and an inactive color group. All widgets contain a palette, and all the widgets in Qt use their palette to draw themselves. This makes the user interface consistent and easily configurable.

If you make a new widget you are strongly advised to use the colors in the palette rather than hard-coding specific colors.

The color groups are:

  • The active() group is used for the window that has keyboard focus.
  • The inactive() group is used for other windows.
  • The disabled() group is used for widgets (not windows) that are disabled for some reason.

Of course, both active and inactive windows can contain disabled widgets. (Disabled widgets are often called inaccessible or grayed out.)

In Motif style, active() and inactive() look precisely the same. In Windows 2000 style and Macintosh Platinum style, the two styles look slightly different.

There are setActive(), setInactive() and setDisabled() functions to modify the palette. Qt also supports a normal() group; this is an obsolete alias for active(), supported for backward compatibility.

(The split between normal() and active() prior to Qt 2.1 did not work except in the simplest of cases, hence the change to the current, more powerful design.)

See also QApplication::setPalette(), QWidget::setPalette(), QColorGroup and QColor.

Examples: i18n/main.cpp


Member Function Documentation

QPalette::QPalette ()

Constructs a palette that consists of color groups with only black colors.

QPalette::QPalette ( const QColor & button )

This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.

Constructs a palette from the button color. The other colors are automatically calculated, based on this color. Background will be the button color as well.

QPalette::QPalette ( const QColor & button, const QColor & background )

Constructs a palette from a button color and a background. The other colors are automatically calculated, based on these colors.

QPalette::QPalette ( const QColorGroup & active, const QColorGroup & disabled, const QColorGroup & inactive )

Constructs a palette that consists of the three color groups active, disabled and inactive. See QPalette for definitions of the color groups and QColorGroup::ColorRole for definitions of each color role in the three groups.

See also QColorGroup, QColorGroup::ColorRole and QPalette.

QPalette::QPalette ( const QPalette & p )

Constructs a copy of p.

This constructor is fast (it uses copy-on-write).

QPalette::~QPalette ()

Destructs the palette.

const QColorGroup & QPalette::active () const

Returns the active color group of this palette.

See also QColorGroup, setActive(), inactive() and disabled().

const QBrush & QPalette::brush ( ColorGroup gr, QColorGroup::ColorRole r ) const

Returns the brush in gr used for color role r.

See also color(), setBrush() and QColorGroup::ColorRole.

const QColor & QPalette::color ( ColorGroup gr, QColorGroup::ColorRole r ) const

Returns the color in gr used for color role r.

See also brush(), setColor() and QColorGroup::ColorRole.

QPalette QPalette::copy () const

Return a deep copy of this palette. This is slower than the copy constructor and assignment operator and offers no advantages any more.

const QColorGroup & QPalette::disabled () const

Returns the disabled color group of this palette.

See also QColorGroup, setDisabled(), active() and inactive().

const QColorGroup & QPalette::inactive () const

Returns the inactive color group of this palette.

See also QColorGroup, setInactive(), active() and disabled().

bool QPalette::isCopyOf ( const QPalette & p )

Returns TRUE if this palette and p are copies of each other, ie. one of them was created as a copy of the other and neither was subsequently modified. This is much stricter than equality.

See also operator= and operator==.

const QColorGroup & QPalette::normal () const

This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.

Use active() instead.

bool QPalette::operator!= ( const QPalette & p ) const

Returns TRUE (slowly) if this palette is different from p, or FALSE (usually quickly) if they are equal.

QPalette & QPalette::operator= ( const QPalette & p )

Assigns p to this palette and returns a reference to this palette.

This is fast (it uses copy-on-write).

See also copy().

bool QPalette::operator== ( const QPalette & p ) const

Returns TRUE (usually quickly) if this palette is equal to p, or FALSE (slowly) if they are different.

int QPalette::serialNumber () const

Returns a number that uniquely identifies this QPalette object. The serial number is intended for caching. Its value may not be used for anything other than equality testing.

Note that QPalette uses copy-on-write, and the serial number changes during the lazy copy operation (detach()), not during a shallow copy (copy constructor or assignment).

See also QPixmap, QPixmapCache and QCache.

void QPalette::setActive ( const QColorGroup & g )

Sets the Active color group to g.

See also active(), setDisabled(), setInactive() and QColorGroup.

void QPalette::setBrush ( QColorGroup::ColorRole r, const QBrush & b )

Sets the brush in for color role r in all three color groups to b.

See also brush(), setColor(), QColorGroup::ColorRole, active(), inactive() and disabled().

void QPalette::setBrush ( ColorGroup gr, QColorGroup::ColorRole r, const QBrush & b )

Sets the brush in gr used for color role r to b.

See also brush(), setColor() and QColorGroup::ColorRole.

void QPalette::setColor ( QColorGroup::ColorRole r, const QColor & c )

Sets the color of the brush in gr used for color role r to c.

See also color(), setBrush() and QColorGroup::ColorRole.

void QPalette::setColor ( ColorGroup gr, QColorGroup::ColorRole r, const QColor & c )

Sets the brush in gr used for color role r to the solid color c.

See also setBrush(), color() and QColorGroup::ColorRole.

void QPalette::setDisabled ( const QColorGroup & g )

Sets the Disabled color group to g.

See also disabled(), setActive() and setInactive().

void QPalette::setInactive ( const QColorGroup & g )

Sets the Inactive color group to g.

See also active(), setDisabled(), setActive() and QColorGroup.

void QPalette::setNormal ( const QColorGroup & g )

This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.

Use setActive() instead.


Related Functions

QDataStream & operator>> (QDataStream & s, QPalette & p)

Reads a palette from the stream and returns a reference to the stream.

See also Format of the QDataStream operators

QDataStream & operator<< (QDataStream & s, const QPalette & p)

Writes a palette to the stream and returns a reference to the stream.

See also Format of the QDataStream operators


Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):


This file is part of the Qt toolkit, copyright © 1995-2005 Trolltech, all rights reserved.

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 ? 72
  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 Labs au hasard

Logo

Chaînes et SIMD, la revanche (de Latin1)

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. 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 2.3
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