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  · 

QColorDialog Class Reference
[QtGui module]

The QColorDialog class provides a dialog widget for specifying colors. More...

 #include <QColorDialog>

Inherits QDialog.

Public Types

Properties

  • 2 properties inherited from QDialog
  • 57 properties inherited from QWidget
  • 1 property inherited from QObject

Public Functions

  • 5 public functions inherited from QDialog
  • 207 public functions inherited from QWidget
  • 29 public functions inherited from QObject
  • 12 public functions inherited from QPaintDevice

Signals

Static Public Members

  • 4 static public members inherited from QWidget
  • 5 static public members inherited from QObject

Protected Functions

  • virtual void done ( int result )
  • 37 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice

Additional Inherited Members

  • 5 public slots inherited from QDialog
  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject
  • 1 protected slot inherited from QWidget

Detailed Description

The QColorDialog class provides a dialog widget for specifying colors.

The color dialog's function is to allow users to choose colors. For example, you might use this in a drawing program to allow the user to set the brush color.

The static functions provide modal color dialogs.

The static getColor() function shows the dialog, and allows the user to specify a color. This function can also be used to let users choose a color with a level of transparency: pass the ShowAlphaChannel option as an additional argument.

The user can store customCount() different custom colors. The custom colors are shared by all color dialogs, and remembered during the execution of the program. Use setCustomColor() to set the custom colors, and use customColor() to get them.

Additional widgets that allow users to pick colors are available as Qt Solutions.

The Standard Dialogs example shows how to use QColorDialog as well as other built-in Qt dialogs.

A color dialog in the Plastique widget style.

See also QColor, QFileDialog, QPrintDialog, QFontDialog, and Standard Dialogs Example.


Member Type Documentation

enum QColorDialog::ColorDialogOption
flags QColorDialog::ColorDialogOptions

This enum specifies various options that affect the look and feel of a color dialog.

ConstantValueDescription
QColorDialog::ShowAlphaChannel0x00000001Allow the user to select the alpha component of a color.
QColorDialog::NoButtons0x00000002Don't display OK and Cancel buttons. (Useful for "live dialogs".)
QColorDialog::DontUseNativeDialog0x00000004Use Qt's standard color dialog on the Mac instead of Apple's native color panel.

This enum was introduced in Qt 4.5.

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

See also options, setOption(), testOption(), and windowModality().


Property Documentation

currentColor : QColor

This property holds the currently selected color in the dialog.

Access functions:

  • QColor currentColor () const
  • void setCurrentColor ( const QColor & color )

options : ColorDialogOptions

This property holds the various options that affect the look and feel of the dialog.

By default, all options are disabled.

Options should be set before showing the dialog. Setting them while the dialog is visible is not guaranteed to have an immediate effect on the dialog (depending on the option and on the platform).

Access functions:

  • ColorDialogOptions options () const
  • void setOptions ( ColorDialogOptions options )

See also setOption() and testOption().


Member Function Documentation

QColorDialog::QColorDialog ( QWidget * parent = 0 )

Constructs a color dialog with the given parent.

This function was introduced in Qt 4.5.

QColorDialog::QColorDialog ( const QColor & initial, QWidget * parent = 0 )

Constructs a color dialog with the given parent and specified initial color.

This function was introduced in Qt 4.5.

QColorDialog::~QColorDialog ()

Destroys the color dialog.

void QColorDialog::colorSelected ( const QColor & color )   [signal]

This signal is emitted just after the user has clicked OK to select a color to use. The chosen color is specified by color.

See also color and currentColorChanged().

void QColorDialog::currentColorChanged ( const QColor & color )   [signal]

This signal is emitted whenever the current color changes in the dialog. The current color is specified by color.

See also color and colorSelected().

QRgb QColorDialog::customColor ( int index )   [static]

Returns the custom color at the given index as a QRgb value.

This function was introduced in Qt 4.5.

See also setCustomColor().

int QColorDialog::customCount ()   [static]

Returns the number of custom colors supported by QColorDialog. All color dialogs share the same custom colors.

void QColorDialog::done ( int result )   [virtual protected]

Closes the dialog and sets its result code to result. If this dialog is shown with exec(), done() causes the local event loop to finish, and exec() to return result.

Reimplemented from QDialog.

See also QDialog::done().

QColor QColorDialog::getColor ( const QColor & initial, QWidget * parent, const QString & title, ColorDialogOptions options = 0 )   [static]

Pops up a modal color dialog with the given window title (or "Select Color" if none is specified), lets the user choose a color, and returns that color. The color is initially set to initial. The dialog is a child of parent. It returns an invalid (see QColor::isValid()) color if the user cancels the dialog.

The options argument allows you to customize the dialog.

This function was introduced in Qt 4.5.

QColor QColorDialog::getColor ( const QColor & initial = Qt::white, QWidget * parent = 0 )   [static]

Pops up a modal color dialog, lets the user choose a color, and returns that color. The color is initially set to initial. The dialog is a child of parent. It returns an invalid (see QColor::isValid()) color if the user cancels the dialog.

void QColorDialog::open ()

Shows the dialog as a window modal dialog, returning immediately.

This function was introduced in Qt 4.5.

See also QDialog::open().

void QColorDialog::open ( QObject * receiver, const char * member )

This is an overloaded function.

Opens the dialog and connects its colorSelected() signal to the slot specified by receiver and member.

The signal will be disconnected from the slot when the dialog is closed.

This function was introduced in Qt 4.5.

QColor QColorDialog::selectedColor () const

Returns the color that the user selected by clicking the OK or equivalent button.

Note: This color is not always the same as the color held by the currentColor property since the user can choose different colors before finally selecting the one to use.

void QColorDialog::setCustomColor ( int index, QRgb color )   [static]

Sets the custom color at index to the QRgb color value.

Note: This function does not apply to the Native Color Dialog on the Mac OS X platform. If you still require this function, use the QColorDialog::DontUseNativeDialog option.

See also customColor().

void QColorDialog::setOption ( ColorDialogOption option, bool on = true )

Sets the given option to be enabled if on is true; otherwise, clears the given option.

See also options and testOption().

void QColorDialog::setStandardColor ( int index, QRgb color )   [static]

Sets the standard color at index to the QRgb color value.

Note: This function does not apply to the Native Color Dialog on the Mac OS X platform. If you still require this function, use the QColorDialog::DontUseNativeDialog option.

void QColorDialog::setVisible ( bool visible )   [virtual]

Changes the visibility of the dialog. If visible is true, the dialog is shown; otherwise, it is hidden.

Reimplemented from QWidget.

bool QColorDialog::testOption ( ColorDialogOption option ) const

Returns true if the given option is enabled; otherwise, returns false.

This function was introduced in Qt 4.5.

See also options and setOption().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 23
  2. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 40
  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. PySide devient un add-on Qt et rejoint le Qt Project et le modèle d'open gouvernance 1
  6. 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
  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 94
  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. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 50
  4. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  5. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 23
  6. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 40
  7. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
Page suivante

Le Qt Labs au hasard

Logo

UTF-8, Latin1 et charsets

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 4.5
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