Avogadro::QtGui::ColorButton#

class ColorButton : public QAbstractButton#

A button to show the current color and bring up the QColorDialog.

This class implements a QAbstractButton to display a colored rectangle. When clicked by the user, it brings up a color picker to select a new color.

Author

Geoffrey Hutchison

The widget has a default minimum size of 35x20 pixels.

Public Functions

ColorButton(QWidget *parent = nullptr)#
explicit ColorButton(const QColor &initial, QWidget *parent = nullptr)#
void paintEvent(QPaintEvent*) override#

Redraw the widget (i.e., refresh the colored rectangle)

void setColor(const QColor &color)#
Parameters:

color – the new color to be used

void setDialogTitle(const QString title = "")#
Parameters:

title – custom title for color choice dialog

QColor color() const#
Returns:

the current color

Public Slots

void changeColor()#

Call for a change in the current color

Signals

void colorChanged(const QColor&)#

emit any time the color is changed, either by a user or by setColor()

Protected Functions

bool event(QEvent *e) override#

Generic event handler, currently defaults to calling parent class (included for future compatibility)

Protected Attributes

QColor m_color#

The current color.

QString m_title#

The current dialog title.