QColorDialog 類

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 對話框。

A color dialog in the Plastique widget style.

另請參閱 QColor , QFileDialog , QPrintDialog , QFontDialog ,和 標準對話框範例 .

成員類型文檔編製

enum QColorDialog:: ColorDialogOption
flags QColorDialog:: ColorDialogOptions

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 ().

特性文檔編製

currentColor : QColor

This property holds the currently selected color in the dialog.

訪問函數:

QColor currentColor () const
void setCurrentColor (const QColor & color )

通知程序信號:

void currentColorChanged (const QColor & color )

options : ColorDialogOptions

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 ().

成員函數文檔編製

QColorDialog:: QColorDialog ( QWidget * parent = 0)

構造顔色對話框采用給定 parent .

該函數在 Qt 4.5 引入。

QColorDialog:: QColorDialog (const QColor & initial , QWidget * parent = 0)

構造顔色對話框采用給定 parent 和指定 initial 顔色。

該函數在 Qt 4.5 引入。

QColorDialog:: ~QColorDialog ()

銷毀顔色對話框。

[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 .

void QColorDialog:: open ()

把對話框展示成 窗口模態對話框 ,立即返迴。

該函數在 Qt 4.5 引入。

另請參閱 QDialog::open ().

void QColorDialog:: open ( QObject * receiver , const char * member )

這是重載函數。

打開對話框並連接其 colorSelected () 信號到槽,指定通過 receiver and member .

將從槽斷開信號連接,當關閉對話框時。

該函數在 Qt 4.5 引入。

QColor QColorDialog:: selectedColor () const

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 ().

void QColorDialog:: setOption ( ColorDialogOption option , bool on = true)

設置給定 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,展示對話框;否則,被隱藏。

bool QColorDialog:: testOption ( ColorDialogOption option ) const

Returns true if the given option 被啓用;否則,返迴 false。

該函數在 Qt 4.5 引入。

另請參閱 options and setOption ().