Toolbox Qt
Loading...
Searching...
No Matches
tbq::ColorButton Class Reference

Button used to pick a color. More...

Inheritance diagram for tbq::ColorButton:
Collaboration diagram for tbq::ColorButton:

Public Types

enum class  ColorShape { COLOR_SHAPE_CIRCLE = 0 , COLOR_SHAPE_RECT }
 

Signals

void sColorChanged (const QColor &color)
 Signal emitted when new color has been selected.
 

Public Member Functions

 Q_ENUM (ColorShape)
 
 ColorButton (QWidget *parent=nullptr)
 Create default color button.
 
ColorShape getShape () const
 Use to get button current shape.
 
const QColor & getColor () const
 Use to get selected color.
 
void setShape (ColorShape shape)
 Use to set button shape.
 
void setColor (const QColor &color)
 Use to set selected color.
 

Protected Member Functions

void paintEvent (QPaintEvent *event) override
 

Detailed Description

Button used to pick a color.

Include with:

#include "toolboxqt/widgets/colorbutton.h"

Create a button that allow to pick a color when clicking on it and display the selected color

Constructor & Destructor Documentation

◆ ColorButton()

tbq::ColorButton::ColorButton ( QWidget * parent = nullptr)
explicit

Create default color button.

By default, shape is set to ColorShape::COLOR_SHAPE_RECT and color to Qt::white.

Parameters
[in,out]parentParent widget.

Member Function Documentation

◆ getShape()

ColorButton::ColorShape tbq::ColorButton::getShape ( ) const

Use to get button current shape.

Returns
Returns shape of the button
See also
setShape()

◆ getColor()

const QColor & tbq::ColorButton::getColor ( ) const

Use to get selected color.

Returns
Returns currently selected color
See also
setColor()

◆ setShape()

void tbq::ColorButton::setShape ( ColorShape shape)

Use to set button shape.

Parameters
[in]shapeShape to use.
See also
getShape()

◆ setColor()

void tbq::ColorButton::setColor ( const QColor & color)

Use to set selected color.

Allow to manually set selected color which will update displayed color and related tooltip button.

Parameters
[in]colorColor to set.
If invalid or same as already selected, nothing is performed.
See also
getColor()
colorChanged()

◆ sColorChanged

void tbq::ColorButton::sColorChanged ( const QColor & color)
signal

Signal emitted when new color has been selected.

See also
getColor(), setColor()

The documentation for this class was generated from the following files: