Compound list   File list   Compound Members   Related Pages  

QValueSelector Class Reference

Slider with Value-based gradient background. More...

List of all members.

Public Members

Public Slots

Signals

Protected Members


Detailed Description

Slider with Value-based gradient background.

This class provides a slider with the background changing from 0 to maximum Value of the specified color. It can be used together with QHSSelector to allow selection of a color in HSV color space.

It contains only one signal, as there is only one value that can be changed by user. Yet there are three 'set' signals which is neccessary as the control also needs information about Hue and Saturation to properly update its background. In the code it could be connected to the QHSSelector widget in the following manner:

  QHSSelector* hsWidget;
  QValueSelector* vWidget;

  ... (set up the widgets appropriately within their parent) ...

  connect( hsWidget, SIGNAL( hueChanged( int ) ), vWidget, SLOT( setHue( int ) ) );
  connect( hsWidget, SIGNAL( saturationChanged( int ) ), vWidget, SLOT( setSaturation( int ) ) );

  ...

  QColor current_color = QColor( hsWidget->hue(), hsWidget->saturation(), vWidget->value() ,QColor::Hsv );

The Value can be in a range <0 ... 255>.

See also:
QHSSelector


Member Function Documentation

QValueSelector::QValueSelector(QWidget* parent = 0, char * name = 0)

Constructor.

This method constructs the QValueSelector object. It passes the arguments parent and name to QLabel constructor. The widget that is constructed has a fixed size of 10x128 pixels. The dafault background is a gradient from black to white.

Parameters:
parent - widget's parent passed to QLabel constructor
name - widget's name passed to QLabel constructor

QValueSelector::~QValueSelector()

Destructor.

The destructor does nothing; the Qt framework takes care of cleaning up.

int QValueSelector::value() const

Returns current value.

void QValueSelector::setValue(int v) [slot]

Sets the surrent Value.

After validation of passed value v this method sets iValue member to it. If the iValue has changed, appropriate updates are done on the widget's background and the signal valueChanged() is emited.

void QValueSelector::setHue(int h) [slot]

Sets the surrent Hue.

This method updates the background image of the widget so that it contains only colors with given hue and changing value. In the end it calls update() so that the whole widget is redrawn.

Parameters:
h - hue to be displayed on the slider.

void QValueSelector::setSaturation(int s) [slot]

Sets the surrent Saturation.

This method updates the background image of the widget so that it contains only colors with given saturation and changing value. In the end it calls update() so that the whole widget is redrawn.

Parameters:
s - saturation to be displayed on the slider.

void QValueSelector::valueChanged(int) [signal]

Emited when value changed.

virtual void QValueSelector::paintEvent(QPaintEvent * e) [protected, virtual]

Repaints gradient changing background together with the slider mark.

This method processes paint event by calling the paintEvent() so that the widget's background is updated and then drawing the slider in appropriate position.

Parameters:
e - QPaintEvent object

virtual void QValueSelector::mouseMoveEvent(QMouseEvent* e) [protected, virtual]

Used for user interaction.

This method simply calls setValue() function with appropriate value calculated from the mouse y-coordinate.

virtual void QValueSelector::mousePressEvent(QMouseEvent* e) [protected, virtual]

Used for user interaction.

As the result of pressing the mouse button should be the same as dragging it, this method simply calls mouseMoveEvent() with the same argument.


Member Data Documentation

int QValueSelector::iHue [protected]

Current Hue.

int QValueSelector::iSaturation [protected]

Current Saturation.

int QValueSelector::iValue [protected]

Current Value.


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