KColorButton Class

A pushbutton to display or allow user selection of a color. More...

Header: #include <KColorButton>
CMake: find_package(KF6 REQUIRED COMPONENTS WidgetsAddons)
target_link_libraries(mytarget PRIVATE KF6::WidgetsAddons)
Inherits: QPushButton

Properties

Public Functions

KColorButton(QWidget *parent = nullptr)
KColorButton(const QColor &c, QWidget *parent = nullptr)
KColorButton(const QColor &c, const QColor &defaultColor, QWidget *parent = nullptr)
QColor color() const
QColor defaultColor() const
(since 4.5) bool isAlphaChannelEnabled() const
(since 4.5) void setAlphaChannelEnabled(bool alpha)
void setColor(const QColor &c)
void setDefaultColor(const QColor &c)

Signals

void changed(const QColor &newColor)

Detailed Description

This widget can be used to display or allow user selection of a color.

KColorButton Widget

See also QColorDialog.

Property Documentation

alphaChannelEnabled : bool

Access functions:

bool isAlphaChannelEnabled() const
void setAlphaChannelEnabled(bool alpha)

color : QColor

Access functions:

QColor color() const
void setColor(const QColor &c)

Notifier signal:

void changed(const QColor &newColor)

defaultColor : QColor

Access functions:

QColor defaultColor() const
void setDefaultColor(const QColor &c)

Member Function Documentation

[explicit] KColorButton::KColorButton(QWidget *parent = nullptr)

Creates a color button.

[explicit] KColorButton::KColorButton(const QColor &c, QWidget *parent = nullptr)

Creates a color button with an initial color c.

KColorButton::KColorButton(const QColor &c, const QColor &defaultColor, QWidget *parent = nullptr)

Creates a color button with an initial color c and default color defaultColor.

[signal] void KColorButton::changed(const QColor &newColor)

Emitted when the color of the widget is changed, either with setColor() or via user selection.

Note: Notifier signal for property color.

QColor KColorButton::color() const

Returns the currently chosen color.

Note: Getter function for property color.

See also setColor().

QColor KColorButton::defaultColor() const

Returns the default color or an invalid color if no default color is set.

Note: Getter function for property defaultColor.

See also setDefaultColor().

[since 4.5] bool KColorButton::isAlphaChannelEnabled() const

Returns true if the user is allowed to change the alpha component.

Note: Getter function for property alphaChannelEnabled.

This function was introduced in 4.5.

[since 4.5] void KColorButton::setAlphaChannelEnabled(bool alpha)

When set to true, allow the user to change the alpha component of the color. The default value is false.

Note: Setter function for property alphaChannelEnabled.

This function was introduced in 4.5.

See also isAlphaChannelEnabled().

void KColorButton::setColor(const QColor &c)

Sets the current color to c.

Note: Setter function for property color.

See also color().

void KColorButton::setDefaultColor(const QColor &c)

Sets the default color to c.

Note: Setter function for property defaultColor.

See also defaultColor().