#include <CustomColorButton.h>
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 |
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.
| CustomColorButton::CustomColorButton | ( | QWidget * | parent = 0 |
) |
Creates a new color button with no text and a default color of Qt::black.
| 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.
| 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.
| 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.
| QColor CustomColorButton::getColor | ( | ) | const |
Returns the current button color.
| ColorType CustomColorButton::getColorType | ( | ) | const |
Returns the current button color.
Convenience method that converts the QColor back into a ColorType.
| bool CustomColorButton::isPopupGridUsed | ( | ) | const |
Queries whether clicking the button invokes a popup color grid.
| void CustomColorButton::setColor | ( | const QColor & | clrNew | ) | [slot] |
Sets the button color.
| 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.
| clrNew | The new button color. Must be a valid color. |
| void CustomColorButton::usePopupGrid | ( | bool | bGrid | ) | [slot] |
Toggles the behavior when the button is clicked.
| 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.
| clrNew | The new button color. |