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

#include <colorcombobox.h>

Inheritance diagram for Widgets::ColorComboBox:
Collaboration diagram for Widgets::ColorComboBox:

Public Member Functions

 ColorComboBox (QWidget *parent=0)
 构造颜色下拉框类, 初始化颜色下拉框. More...
 
void setColor (const QColor &c)
 设置当前颜色. More...
 
QColor color () const
 获取当前颜色. More...
 

Static Public Member Functions

static QList< QColor > colorList ()
 获取颜色下拉框的颜色列表. More...
 
static QStringList colorNames ()
 获取颜色下拉框的颜色名称列表. More...
 
static int colorIndex (const QColor &c)
 获取颜色的索引值. More...
 
static QColor color (int colorIndex)
 获取给定索引值的颜色. More...
 
static QColor defaultColor (int colorIndex)
 获取给定索引值的颜色. More...
 
static bool isValidColor (const QColor &color)
 判断是否是一个有效的颜色. More...
 
static int numPredefinedColors ()
 获取颜色下拉框内置颜色数. More...
 
static QStringList defaultColorNames ()
 获取默认颜色名列表. More...
 
static QList< QColor > defaultColors ()
 获取默认颜色列表. More...
 

Protected Member Functions

void init ()
 初始化颜色下拉框. More...
 

Static Protected Attributes

static const int stColorsCount = 24
 
static const QColor stColors []
 

Detailed Description

Definition at line 16 of file colorcombobox.h.

Constructor & Destructor Documentation

◆ ColorComboBox()

Widgets::ColorComboBox::ColorComboBox ( QWidget *  parent = 0)

构造颜色下拉框类, 初始化颜色下拉框.

Parameters
parent,父窗口.

Definition at line 38 of file colorcombobox.cpp.

References init().

Member Function Documentation

◆ color() [1/2]

QColor Widgets::ColorComboBox::color ( ) const

获取当前颜色.

Returns
当前颜色.

Definition at line 76 of file colorcombobox.cpp.

Referenced by isValidColor().

◆ color() [2/2]

QColor Widgets::ColorComboBox::color ( int  colorIndex)
static

获取给定索引值的颜色.

Parameters
colorIndex,颜色的索引值.
Returns
给定索引值的颜色, 如果给定索引值超出范围,或者在颜色框中没有找到,也返回黑色.

Definition at line 95 of file colorcombobox.cpp.

References ecvColor::black(), colorIndex(), and colorList().

◆ colorIndex()

int Widgets::ColorComboBox::colorIndex ( const QColor &  c)
static

获取颜色的索引值.

Parameters
c,需要查找索引的颜色.
Returns
颜色的索引位置值.

Definition at line 83 of file colorcombobox.cpp.

References colorList(), and isValidColor().

Referenced by color(), defaultColor(), and setColor().

◆ colorList()

QList< QColor > Widgets::ColorComboBox::colorList ( )
static

获取颜色下拉框的颜色列表.

Returns
颜色下拉框的颜色列表.

Definition at line 107 of file colorcombobox.cpp.

References stColors, and stColorsCount.

Referenced by color(), colorIndex(), Widgets::ColorPushButton::ColorPushButton(), init(), and isValidColor().

◆ colorNames()

QStringList Widgets::ColorComboBox::colorNames ( )
static

获取颜色下拉框的颜色名称列表.

Returns
颜色下拉框的颜色名称列表.

Definition at line 129 of file colorcombobox.cpp.

References defaultColorNames().

Referenced by Widgets::ColorPushButton::ColorPushButton(), and init().

◆ defaultColor()

QColor Widgets::ColorComboBox::defaultColor ( int  colorIndex)
static

获取给定索引值的颜色.

Parameters
colorIndex,颜色的索引值.
Returns
给定索引值的颜色, 如果给定索引值超出范围,或者在颜色框中没有找到,也返回黑色.

Definition at line 147 of file colorcombobox.cpp.

References ecvColor::black(), colorIndex(), and stColors.

◆ defaultColorNames()

QStringList Widgets::ColorComboBox::defaultColorNames ( )
static

获取默认颜色名列表.

Returns
默认颜色名列表.

Definition at line 173 of file colorcombobox.cpp.

Referenced by colorNames(), and Widgets::ColorPushButton::ColorPushButton().

◆ defaultColors()

QList< QColor > Widgets::ColorComboBox::defaultColors ( )
static

获取默认颜色列表.

Returns
默认颜色列表.

Definition at line 205 of file colorcombobox.cpp.

References stColors, and stColorsCount.

Referenced by Widgets::ColorPushButton::ColorPushButton().

◆ init()

void Widgets::ColorComboBox::init ( )
protected

初始化颜色下拉框.

Definition at line 46 of file colorcombobox.cpp.

References colorList(), and colorNames().

Referenced by ColorComboBox().

◆ isValidColor()

bool Widgets::ColorComboBox::isValidColor ( const QColor &  color)
static

判断是否是一个有效的颜色.

Parameters
color一个颜色.
Returns
返回true表示是颜色有效, 否则无效.

Definition at line 159 of file colorcombobox.cpp.

References color(), and colorList().

Referenced by colorIndex().

◆ numPredefinedColors()

int Widgets::ColorComboBox::numPredefinedColors ( )
static

获取颜色下拉框内置颜色数.

Returns
颜色下拉框内置颜色数.

Definition at line 167 of file colorcombobox.cpp.

References stColorsCount.

Referenced by Widgets::ColorPushButton::ColorPushButton().

◆ setColor()

void Widgets::ColorComboBox::setColor ( const QColor &  c)

设置当前颜色.

Parameters
c颜色.

Definition at line 68 of file colorcombobox.cpp.

References colorIndex().

Member Data Documentation

◆ stColors

const QColor Widgets::ColorComboBox::stColors
staticprotected
Initial value:
= {
QColor(Qt::black), QColor(Qt::red), QColor(Qt::green),
QColor(Qt::blue), QColor(Qt::cyan), QColor(Qt::magenta),
QColor(Qt::yellow), QColor(Qt::darkYellow), QColor(Qt::darkBlue),
QColor(Qt::darkMagenta), QColor(Qt::darkRed), QColor(Qt::darkGreen),
QColor(Qt::darkCyan), QColor("#0000A0"), QColor("#FF8000"),
QColor("#8000FF"), QColor("#FF0080"), QColor(Qt::white),
QColor(Qt::lightGray), QColor(Qt::gray), QColor("#FFFF80"),
QColor("#80FFFF"), QColor("#FF80FF"), QColor(Qt::darkGray),
}
constexpr Rgb cyan(0, MAX, MAX)
constexpr Rgb black(0, 0, 0)
constexpr Rgb magenta(MAX, 0, MAX)
constexpr Rgb darkBlue(0, 0, MAX/2)
constexpr Rgb white(MAX, MAX, MAX)
constexpr Rgb red(MAX, 0, 0)
constexpr Rgb blue(0, 0, MAX)
constexpr Rgb green(0, MAX, 0)
constexpr Rgb yellow(MAX, MAX, 0)

Definition at line 36 of file colorcombobox.h.

Referenced by colorList(), defaultColor(), and defaultColors().

◆ stColorsCount

const int Widgets::ColorComboBox::stColorsCount = 24
staticprotected

Definition at line 35 of file colorcombobox.h.

Referenced by colorList(), defaultColors(), and numPredefinedColors().


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