The QColorDialog class provides a dialog widget for specifying colors. 更多...
| 头: | #include <QColorDialog> |
| 继承: | QDialog |
| enum | ColorDialogOption { ShowAlphaChannel, NoButtons, DontUseNativeDialog } |
| flags | ColorDialogOptions |
| QColorDialog (QWidget * parent = 0) | |
| QColorDialog (const QColor & initial , QWidget * parent = 0) | |
| ~QColorDialog () | |
| QColor | currentColor () const |
| void | open () |
| void | open (QObject * receiver , const char * member ) |
| ColorDialogOptions | options () const |
| QColor | selectedColor () const |
| void | setCurrentColor (const QColor & color ) |
| void | setOption (ColorDialogOption option , bool on = true) |
| void | setOptions (ColorDialogOptions options ) |
| bool | testOption (ColorDialogOption option ) const |
| virtual void | setVisible (bool visible ) |
| void | colorSelected (const QColor & color ) |
| void | currentColorChanged (const QColor & color ) |
| QRgb | customColor (int index ) |
| int | customCount () |
| QColor | getColor (const QColor & initial , QWidget * parent , const QString & title , ColorDialogOptions options = 0) |
| QColor | getColor (const QColor & initial = Qt::white, QWidget * parent = 0) |
| void | setCustomColor (int index , QRgb color ) |
| void | setStandardColor (int index , QRgb color ) |
| virtual void | changeEvent (QEvent * e ) |
| virtual void | done (int result ) |
The QColorDialog class provides a dialog widget for specifying colors.
The color dialog's function is to allow users to choose colors. For example, you might use this in a drawing program to allow the user to set the brush color.
静态函数提供模态颜色对话框。
静态 getColor () function shows the dialog, and allows the user to specify a color. This function can also be used to let users choose a color with a level of transparency: pass the ShowAlphaChannel option as an additional argument.
用户可以存储 customCount () different custom colors. The custom colors are shared by all color dialogs, and remembered during the execution of the program. Use setCustomColor () to set the custom colors, and use customColor () to get them.
The 标准对话框 范例展示如何使用 QColorDialog 及其它内置 Qt 对话框。
另请参阅 QColor , QFileDialog , QPrintDialog , QFontDialog ,和 标准对话框范例 .
This enum specifies various options that affect the look and feel of a color dialog.
| 常量 | 值 | 描述 |
|---|---|---|
QColorDialog::ShowAlphaChannel
|
0x00000001
|
Allow the user to select the alpha component of a color. |
QColorDialog::NoButtons
|
0x00000002
|
不显示 OK and Cancel buttons. (Useful for "live dialogs".) |
QColorDialog::DontUseNativeDialog
|
0x00000004
|
Use Qt's standard color dialog on the Mac instead of the operating system native color dialog. |
该枚举在 Qt 4.5 引入或被修改。
ColorDialogOptions 类型是 typedef 对于 QFlags <ColorDialogOption>. It stores an OR combination of ColorDialogOption values.
另请参阅 options , setOption (), testOption (),和 windowModality ().
This property holds the currently selected color in the dialog.
访问函数:
| QColor | currentColor () const |
| void | setCurrentColor (const QColor & color ) |
通知程序信号:
| void | currentColorChanged (const QColor & color ) |
This property holds the various options that affect the look and feel of the dialog.
默认情况下,所有选项是被禁用的。
Options should be set before showing the dialog. Setting them while the dialog is visible is not guaranteed to have an immediate effect on the dialog (depending on the option and on the platform).
访问函数:
| ColorDialogOptions | options () const |
| void | setOptions (ColorDialogOptions options ) |
另请参阅 setOption () 和 testOption ().
构造颜色对话框采用给定 parent .
该函数在 Qt 4.5 引入。
构造颜色对话框采用给定 parent 和指定 initial 颜色。
该函数在 Qt 4.5 引入。
销毁颜色对话框。
[virtual protected]
void
QColorDialog::
changeEvent
(
QEvent
*
e
)
重实现自 QWidget::changeEvent ().
[signal]
void
QColorDialog::
colorSelected
(const
QColor
&
color
)
This signal is emitted just after the user has clicked OK to select a color to use. The chosen color is specified by color .
另请参阅 color and currentColorChanged ().
[static]
QRgb
QColorDialog::
customColor
(
int
index
)
返回自定义颜色在给定 index 作为 QRgb 值。
该函数在 Qt 4.5 引入。
另请参阅 setCustomColor ().
[static]
int
QColorDialog::
customCount
()
Returns the number of custom colors supported by QColorDialog . All color dialogs share the same custom colors.
[virtual protected]
void
QColorDialog::
done
(
int
result
)
重实现自 QDialog::done ().
关闭对话框并将其结果代码设为 result 。若此对话框的展示是采用 exec (),done() 导致本地事件循环的完成,且 exec () 返回 result .
另请参阅 QDialog::done ().
[static]
QColor
QColorDialog::
getColor
(const
QColor
&
initial
,
QWidget
*
parent
, const
QString
&
title
,
ColorDialogOptions
options
= 0)
Pops up a modal color dialog with the given window title (or "Select Color" if none is specified), lets the user choose a color, and returns that color. The color is initially set to initial . The dialog is a child of parent . It returns an invalid (see QColor::isValid ()) color if the user cancels the dialog.
The options 自变量允许您定制对话框。
On Symbian, this static function will use the native color dialog and not a QColorDialog . On Symbian the parameters title and parent has no relevance and the options parameter is only used to define if the native color dialog is used or not.
该函数在 Qt 4.5 引入。
[static]
QColor
QColorDialog::
getColor
(const
QColor
&
initial
= Qt::white,
QWidget
*
parent
= 0)
Pops up a modal color dialog, lets the user choose a color, and returns that color. The color is initially set to initial . The dialog is a child of parent . It returns an invalid (see QColor::isValid ()) color if the user cancels the dialog.
On Symbian, this static function will use the native color dialog and not a QColorDialog .
把对话框展示成 窗口模态对话框 ,立即返回。
该函数在 Qt 4.5 引入。
另请参阅 QDialog::open ().
这是重载函数。
打开对话框并连接其 colorSelected () 信号到槽,指定通过 receiver and member .
将从槽断开信号连接,当关闭对话框时。
该函数在 Qt 4.5 引入。
Returns the color that the user selected by clicking the OK or equivalent button.
注意: This color is not always the same as the color held by the currentColor property since the user can choose different colors before finally selecting the one to use.
[static]
void
QColorDialog::
setCustomColor
(
int
index
,
QRgb
color
)
设置自定义颜色在 index 到 QRgb color 值。
注意: This function does not apply to the Native Color Dialog on the Mac OS X platform. If you still require this function, use the QColorDialog::DontUseNativeDialog 选项。
另请参阅 customColor ().
设置给定 option 为被启用若 on 为 true;否则,清零给定 option .
另请参阅 options and testOption ().
[static]
void
QColorDialog::
setStandardColor
(
int
index
,
QRgb
color
)
设置标准颜色在 index 到 QRgb color 值。
注意: This function does not apply to the Native Color Dialog on the Mac OS X platform. If you still require this function, use the QColorDialog::DontUseNativeDialog 选项。
[虚拟]
void
QColorDialog::
setVisible
(
bool
visible
)
重实现自 QWidget::setVisible ().
更改对话框的可见性。若 visible 为 true,展示对话框;否则,被隐藏。
Returns true if the given option 被启用;否则,返回 false。
该函数在 Qt 4.5 引入。