CustomColorButton Class Reference

A push button to get a selected color from the user. More...

#include <CustomColorButton.h>

List of all members.

Public Slots

void setColor (const QColor &clrNew)
void setColor (const ColorType &clrNew)
void usePopupGrid (bool bGrid)

Signals

void colorChanged (const QColor &clrNew)

Public Member Functions

 CustomColorButton (QWidget *parent=0)
 CustomColorButton (const QString &strText, QWidget *parent=0)
 CustomColorButton (const QString &strText, const QColor &color, QWidget *parent=0)
 ~CustomColorButton ()
QColor getColor () const
ColorType getColorType () const
bool isPopupGridUsed () const


Detailed Description

A push button to get a selected color from the user.

The custom color button allows users to select a color and displays a pixmap of the currently selected color. Optional text can be displayed next to the color using the QPushButton::setText() method.

When the user clicks the button, a common color dialog is invoked in which the user can select a new color. By calling usePopupGrid(), this behavior can change to invoke a popup color grid and a Custom menu command. The user can then select a color from the grid or select the Custom command to invoke the common color dialog. When a popup color grid is used, a down arrow appears on the right side of the button.

Regardless of the behavior when the button is clicked, the pixmap automatically updates when a new color is selected.

Definition at line 37 of file CustomColorButton.h.


Constructor & Destructor Documentation

CustomColorButton::CustomColorButton ( QWidget *  parent = 0  ) 

Creates a new color button with no text and a default color of Qt::black.

Parameters:
parent The parent widget.

CustomColorButton::CustomColorButton ( const QString &  strText,
QWidget *  parent = 0 
)

Creates a new color button with text strText and a default color of Qt::black.

Parameters:
strText The text to appear on the button.
parent The parent widget.

CustomColorButton::CustomColorButton ( const QString &  strText,
const QColor &  color,
QWidget *  parent = 0 
)

Creates a new color button with text strText and color color.

Parameters:
strText The text to appear on the button.
color The initial color for the button.
parent The parent widget.

CustomColorButton::~CustomColorButton (  ) 

Destroys the color button.


Member Function Documentation

QColor CustomColorButton::getColor (  )  const

Returns the current button color.

Returns:
The button color.

ColorType CustomColorButton::getColorType (  )  const

Returns the current button color.

Convenience method that converts the QColor back into a ColorType.

Returns:
The button color.

bool CustomColorButton::isPopupGridUsed (  )  const

Queries whether clicking the button invokes a popup color grid.

Returns:
Returns true if clicking the button invokes a popup color grid. Returns false if clicking the button invokes a common color dialog.

void CustomColorButton::setColor ( const QColor &  clrNew  )  [slot]

Sets the button color.

Parameters:
clrNew The new button color. Must be a valid color.

void CustomColorButton::setColor ( const ColorType clrNew  )  [slot]

Sets the button color.

Convenience method that converts the ColorType into a QColor.

Parameters:
clrNew The new button color. Must be a valid color.

void CustomColorButton::usePopupGrid ( bool  bGrid  )  [slot]

Toggles the behavior when the button is clicked.

Parameters:
bGrid Pass in a value of true to invoke a popup color grid when the button is clicked. Pass in a value of false to invoke a common color dialog when the button is clicked.

void CustomColorButton::colorChanged ( const QColor &  clrNew  )  [signal]

This signal is emitted when the button color changes.

The color changes when the user selects a new color or when the color is set programmatically.

Parameters:
clrNew The new button color.


Software Development Kit - Opticks 4.9.0 Build 16218