ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Widgets::QtColorPicker Class Reference

#include <qtcolorpicker.h>

Inheritance diagram for Widgets::QtColorPicker:
Collaboration diagram for Widgets::QtColorPicker:

Public Slots

void setCurrentColor (const QColor &col)
 

Signals

void colorChanged (const QColor &)
 

Public Member Functions

 QtColorPicker (QWidget *parent=0, int columns=-1, bool enableColorDialog=true)
 
 ~QtColorPicker ()
 
void insertColor (const QColor &color, const QString &text=QString(), int index=-1)
 
QColor currentColor () const
 
QColor color (int index) const
 
void setColorDialogEnabled (bool enabled)
 
bool colorDialogEnabled () const
 
void setStandardColors ()
 

Static Public Member Functions

static QColor GetColor (const QPoint &pos, bool allowCustomColors=true)
 

Protected Member Functions

void paintEvent (QPaintEvent *e)
 

Properties

bool colorDialog
 Whether the ellipsis "..." (more) button is available. More...
 

Detailed Description

Definition at line 22 of file qtcolorpicker.h.

Constructor & Destructor Documentation

◆ QtColorPicker()

QtColorPicker::QtColorPicker ( QWidget *  parent = 0,
int  cols = -1,
bool  enableColorDialog = true 
)

Constructs a QtColorPicker widget. The popup will display a grid with cols columns, or if cols is -1, the number of columns will be calculated automatically.

If enableColorDialog is true, the popup will also have a "More" button (signified by an ellipsis "...") that presents a QColorDialog when clicked.

After constructing a QtColorPicker, call insertColor() to add individual colors to the popup grid, or call setStandardColors() to add all the standard colors in one go.

The parent argument is passed to QFrame's constructor.

See also
QFrame

Definition at line 235 of file qtcolorpicker.cpp.

References ecvColor::black(), cloudViewer::core::Minimum(), and setCurrentColor().

◆ ~QtColorPicker()

QtColorPicker::~QtColorPicker ( )

Destructs the QtColorPicker.

Definition at line 264 of file qtcolorpicker.cpp.

Member Function Documentation

◆ color()

QColor QtColorPicker::color ( int  index) const

Returns the color at position index.

Definition at line 343 of file qtcolorpicker.cpp.

References Widgets::ColorPickerPopup::color().

Referenced by insertColor(), paintEvent(), and setCurrentColor().

◆ colorChanged

QtColorPicker::colorChanged ( const QColor &  color)
signal
This signal is emitted when the QtColorPicker's color is changed.
\a color is the new color.

To obtain the color's name, use text().

Referenced by setCurrentColor().

◆ colorDialogEnabled()

bool QtColorPicker::colorDialogEnabled ( ) const

Definition at line 429 of file qtcolorpicker.cpp.

◆ currentColor()

QColor QtColorPicker::currentColor ( ) const

Returns the currently selected color.

See also
text()

Definition at line 338 of file qtcolorpicker.cpp.

◆ GetColor()

QColor QtColorPicker::GetColor ( const QPoint &  point,
bool  allowCustomColors = true 
)
static
 Pops up a color grid with Qt default colors at \a point, using
 global coordinates. If \a allowCustomColors is true, there will
 also be a button on the popup that invokes QColorDialog.

 For example:

 \code
         void Drawer::mouseReleaseEvent(QMouseEvent *e)
         {
         if (e->button() & RightButton) {
                         QColor color =

QtColorPicker::GetColor(mapToGlobal(e->pos())); } }

Definition at line 448 of file qtcolorpicker.cpp.

References ecvColor::black(), ecvColor::blue(), ecvColor::cyan(), ecvColor::darkBlue(), Widgets::ColorPickerPopup::exec(), ecvColor::green(), Widgets::ColorPickerPopup::insertColor(), Widgets::ColorPickerPopup::lastSelected(), ecvColor::magenta(), ecvColor::red(), ecvColor::white(), and ecvColor::yellow().

◆ insertColor()

void QtColorPicker::insertColor ( const QColor &  color,
const QString &  text = QString(),
int  index = -1 
)

Adds the color color with the name text to the color grid, at position index. If index is -1, the color is assigned automatically assigned a position, starting from left to right, top to bottom.

Definition at line 407 of file qtcolorpicker.cpp.

References color(), and Widgets::ColorPickerPopup::insertColor().

Referenced by Widgets::ColorPushButton::ColorPushButton(), setCurrentColor(), and setStandardColors().

◆ paintEvent()

void QtColorPicker::paintEvent ( QPaintEvent *  e)
protected

Definition at line 304 of file qtcolorpicker.cpp.

References color(), and e.

◆ setColorDialogEnabled()

void QtColorPicker::setColorDialogEnabled ( bool  enabled)

Definition at line 426 of file qtcolorpicker.cpp.

◆ setCurrentColor

void QtColorPicker::setCurrentColor ( const QColor &  color)
slot

Makes color current. If color is not already in the color grid, it is inserted with the text "Custom".

This function emits the colorChanged() signal if the new color is valid, and different from the old one.

Definition at line 380 of file qtcolorpicker.cpp.

References color(), colorChanged(), Widgets::ColorPickerPopup::find(), insertColor(), Widgets::ColorPickerItem::setSelected(), and Widgets::ColorPickerItem::text().

Referenced by QtColorPicker().

◆ setStandardColors()

void QtColorPicker::setStandardColors ( )

Adds the 17 predefined colors from the Qt namespace.

(The names given to the colors, "Black", "White", "Red", etc., are all translatable.)

See also
insertColor()

Definition at line 353 of file qtcolorpicker.cpp.

References ecvColor::black(), ecvColor::blue(), ecvColor::cyan(), ecvColor::darkBlue(), ecvColor::green(), insertColor(), ecvColor::magenta(), ecvColor::red(), ecvColor::white(), and ecvColor::yellow().

Property Documentation

◆ colorDialog

QtColorPicker::colorDialog
read

Whether the ellipsis "..." (more) button is available.

If this property is set to TRUE, the color grid popup will include a "More" button (signified by an ellipsis, "...") which pops up a QColorDialog when clicked. The user will then be able to select any custom color they like.

Definition at line 1 of file qtcolorpicker.h.


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