QGIS API Documentation
2.8.2-Wien
|
A cross platform button subclass for selecting colors. Will open a color chooser dialog when clicked. Offers live updates to button from color chooser dialog. More...
#include <qgscolorbutton.h>
Public Slots | |
void | setButtonBackground (QColor color=QColor()) |
Sets the background pixmap for the button based upon color and transparency. |
Signals | |
void | colorChanged (const QColor &color) |
Is emitted, whenever a new color is accepted. |
Public Member Functions | |
QgsColorButton (QWidget *parent=0, QString cdt="", QColorDialog::ColorDialogOptions cdo=0) | |
Construct a new color button. | |
~QgsColorButton () | |
bool | acceptLiveUpdates () |
Whether the button accepts live updates from QColorDialog. | |
QColor | color () const |
Return the currently selected color. | |
QColorDialog::ColorDialogOptions | colorDialogOptions () |
Returns the options for the color chooser dialog. | |
QString | colorDialogTitle () |
Returns the title, which the color chooser dialog shows. | |
void | setAcceptLiveUpdates (bool accept) |
Sets whether the button accepts live updates from QColorDialog. | |
void | setColor (const QColor &color) |
Specify the current color. | |
void | setColorDialogOptions (QColorDialog::ColorDialogOptions cdo) |
Specify the options for the color chooser dialog (e.g. | |
void | setColorDialogTitle (QString cdt) |
Set the title, which the color chooser dialog will show. |
Protected Member Functions | |
void | changeEvent (QEvent *e) override |
void | dragEnterEvent (QDragEnterEvent *e) override |
Reimplemented to accept dragged colors. | |
void | dropEvent (QDropEvent *e) override |
Reimplemented to accept dropped colors. | |
void | keyPressEvent (QKeyEvent *e) override |
Reimplemented to allow cancelling color pick via keypress, and sample via space bar press. | |
void | mouseMoveEvent (QMouseEvent *e) override |
Reimplemented to allow dragging colors from button. | |
void | mousePressEvent (QMouseEvent *e) override |
Reimplemented to detect right mouse button clicks on the color button and allow dragging colors. | |
void | mouseReleaseEvent (QMouseEvent *e) override |
Reimplemented to allow color picking. | |
void | showEvent (QShowEvent *e) override |
Static Protected Member Functions | |
static const QPixmap & | transpBkgrd () |
Properties | |
bool | acceptLiveUpdates |
QColor | color |
QColorDialog::ColorDialogOptions | colorDialogOptions |
QString | colorDialogTitle |
A cross platform button subclass for selecting colors. Will open a color chooser dialog when clicked. Offers live updates to button from color chooser dialog.
A cross platform button subclass for selecting colors.
A subclass of QPushButton is needed to draw the button content because some platforms such as Mac OS X and Windows XP enforce a consistent GUI look by always using the button color of the current style and not allowing button backgrounds to be changed on a button by button basis. Therefore, a wholely stylesheet-based button is used for the no-text variant.
This class is a simplified version of QtColorButton, an internal class used by Qt Designer to do the same thing.
Will open a color chooser dialog when clicked. Offers live updates to button from color chooser dialog
Definition at line 31 of file qgscolorbutton.h.
QgsColorButton::QgsColorButton | ( | QWidget * | parent = 0 , |
QString | cdt = "" , |
||
QColorDialog::ColorDialogOptions | cdo = 0 |
||
) |
Construct a new color button.
parent | The parent QWidget for the dialog |
cdt | The title to show in the color chooser dialog |
cdo | Options for the color chooser dialog |
Definition at line 67 of file qgscolorbutton.cpp.
QgsColorButton::~QgsColorButton | ( | ) |
Definition at line 81 of file qgscolorbutton.cpp.
|
inline |
Whether the button accepts live updates from QColorDialog.
Definition at line 96 of file qgscolorbutton.h.
|
overrideprotected |
Definition at line 396 of file qgscolorbutton.cpp.
QColor QgsColorButton::color | ( | ) | const |
Return the currently selected color.
|
signal |
Is emitted, whenever a new color is accepted.
The color is always valid. In case the new color is the same, no signal is emitted, to avoid infinite loops.
color | New color |
QColorDialog::ColorDialogOptions QgsColorButton::colorDialogOptions | ( | ) |
Returns the options for the color chooser dialog.
QString QgsColorButton::colorDialogTitle | ( | ) |
Returns the title, which the color chooser dialog shows.
|
overrideprotected |
Reimplemented to accept dragged colors.
Definition at line 316 of file qgscolorbutton.cpp.
|
overrideprotected |
Reimplemented to accept dropped colors.
Definition at line 326 of file qgscolorbutton.cpp.
|
overrideprotected |
Reimplemented to allow cancelling color pick via keypress, and sample via space bar press.
Definition at line 303 of file qgscolorbutton.cpp.
|
overrideprotected |
Reimplemented to allow dragging colors from button.
Definition at line 216 of file qgscolorbutton.cpp.
|
overrideprotected |
Reimplemented to detect right mouse button clicks on the color button and allow dragging colors.
Definition at line 149 of file qgscolorbutton.cpp.
|
overrideprotected |
Reimplemented to allow color picking.
Definition at line 270 of file qgscolorbutton.cpp.
|
inline |
Sets whether the button accepts live updates from QColorDialog.
Live updates may cause changes that are not undoable on QColorDialog cancel.
Definition at line 102 of file qgscolorbutton.h.
|
slot |
Sets the background pixmap for the button based upon color and transparency.
Call directly to update background after adding/removing QColorDialog::ShowAlphaChannel option but the color has not changed, i.e. setColor() wouldn't update button and you want the button to retain the set color's alpha component regardless
color | Color for button background |
Definition at line 446 of file qgscolorbutton.cpp.
void QgsColorButton::setColor | ( | const QColor & | color | ) |
Specify the current color.
Will emit a colorChanged signal if the color is different to the previous.
color | the new color |
Definition at line 423 of file qgscolorbutton.cpp.
void QgsColorButton::setColorDialogOptions | ( | QColorDialog::ColorDialogOptions | cdo | ) |
Specify the options for the color chooser dialog (e.g.
alpha).
cdo | Options for the color chooser dialog |
Definition at line 581 of file qgscolorbutton.cpp.
void QgsColorButton::setColorDialogTitle | ( | QString | cdt | ) |
Set the title, which the color chooser dialog will show.
cdt | Title for the color chooser dialog |
Definition at line 591 of file qgscolorbutton.cpp.
|
overrideprotected |
Definition at line 417 of file qgscolorbutton.cpp.
|
staticprotected |
Definition at line 87 of file qgscolorbutton.cpp.
|
readwrite |
Definition at line 35 of file qgscolorbutton.h.
|
readwrite |
Definition at line 36 of file qgscolorbutton.h.
|
readwrite |
Definition at line 38 of file qgscolorbutton.h.
|
readwrite |
Definition at line 34 of file qgscolorbutton.h.