Compound list   File list   Compound Members   Related Pages  

QColorDlg Class Reference

Color selection dialog class. More...

List of all members.

Public Members

Public Slots

Static Public Members

Protected Members

Protected Slots


Detailed Description

Color selection dialog class.

This class can be used to allow user selection of the color using RGB or HSV color-model. For both of them there are both sliders and spinboxes for value selection. Additionally the HSV model is also represented in a well known form of separate HS chart and V slider.

This dialog may be used as any other in Qt, but it provides also the static function getColor() that can be conviniently used as follows:

  #include "qcolordlg.h"

  ...

  QColor initial_color; // The color that dialog will start with
  QColor result;        // The resulting user's selection
  result = QColorDlg::getColor( initial_color );


Member Function Documentation

QColorDlg::QColorDlg(QWidget* parent = 0, const char * name = 0)

Constructor.

This method constructs the dialog with given parent and name asusually with classes derived from QDialog. Contrary to usual QDialog classes it creates the dialog that is modal.

The implementation of this method is rather long and boring. It contains a lot of geometry management made with ose of Qt layouts, so that the dialog should look OK even if the names of some of the labels are substituted with a very long (or very short) strings.

Parameters:
parent - a widget's parent as passed to QDialog constructor
name - a widget's name as passed to QDialog constructor

QColorDlg::~QColorDlg()

Destructor.

The destructor in fact does nothing, the Qt library kills all the children of the dialog, and those are the only dynamically allocated things here.

QColor QColorDlg::color() const

Returns currently selected color.

void QColorDlg::setColor(const QColor& c) [slot]

Sets current color in the dialog.

This function sets the actual color in the dialog. It does it by updating at first the values of RGB sliders and then calling updateFromRGB() function.

Parameters:
c - color to be set

QColor QColorDlg::getColor(const QColor& initial = black) [static]

Function that returns user's choice.

This function constructs a color selection dialog, runs it and returns the resulting user selection (or initial selection if Cancel was pressed).

Parameters:
initial - initial color that will be shown in the dialog
Returns:
the color selected by user or initial color if Cancel was pressed

void QColorDlg::updateFromRGB() [protected, slot]

Updates the dialog from RGB controls.

This function recalculates the HSV values from the current RGB values and updates the colorLabel to display appropriate color. As this function and updateFromHSV() shouldn't overlap, this one first checks for isHsvUpdating and returns silently if true. In the other case it sets isRgbUpdating so that updateFromHSV() will not interfere.

See also:
updateFromHSV()

void QColorDlg::updateFromHSV() [protected, slot]

Updates the dialog from HSV controls.

This function updates the RGB values from current HSV values. It is complmentary to updateFromRGB().

See also:
updateFromRGB()


Member Data Documentation

QColor QColorDlg::cur_color [protected]

Currently selected color.

QLabel* QColorDlg::colorLabel [protected]

The label on which the color is displayed.

QSlider* QColorDlg::rSlider [protected]

Red component slider.

QSlider* QColorDlg::gSlider [protected]

Green component slider.

QSlider* QColorDlg::bSlider [protected]

Blue component slider.

QSlider* QColorDlg::hSlider [protected]

Hue component slider.

QSlider* QColorDlg::sSlider [protected]

Saturation component slider.

QSlider* QColorDlg::vSlider [protected]

Value component slider.

bool QColorDlg::isRgbUpdating [protected]

Flag for indicating that the dialog is within updating its state from RGB controls.

bool QColorDlg::isHsvUpdating [protected]

Flag for indicating that the dialog is within updating its state from HSV controls.


The documentation for this class was generated from the following files:
Generated at Mon Jun 7 15:00:44 1999 for Qt Color Selection Dialog by doxygen  written by Dimitri van Heesch, © 1997-1998