QColorDialogclass provides a dialog widget for specifying colors. 更多 …
def
currentColor
()
def
open
(receiver, member)
def
options
()
def
selectedColor
()
def
setCurrentColor
(color)
def
setOption
(option[, on=true])
def
setOptions
(options)
def
testOption
(option)
def
colorSelected
(color)
def
currentColorChanged
(color)
def
customColor
(index)
def
customCount
()
def
getColor
([initial=Qt.white[, parent=None[, title=””[, options=QColorDialog.ColorDialogOptions()]]]])
def
setCustomColor
(index, color)
def
setStandardColor
(index, color)
def
standardColor
(index)
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.
The static functions provide modal color dialogs.
静态
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 theShowAlphaChanneloption as an additional argument.The user can store
customCount()different custom colors. The custom colors are shared by all color dialogs, and remembered during the execution of the program. UsesetCustomColor()to set the custom colors, and usecustomColor()to get them.When pressing the “Pick Screen Color” button, the cursor changes to a haircross and the colors on the screen are scanned. The user can pick up one by clicking the mouse or the Enter button. Pressing Escape restores the last color selected before entering this mode.
标准对话框 example shows how to use
QColorDialogas well as other built-in Qt dialogs.![]()
另请参阅
QColorQFileDialogQFontDialog标准对话框范例
QColorDialog
(
[
parent=None
]
)
¶
QColorDialog(initial[, parent=None])
- param parent
- param initial
QColor
Constructs a color dialog with the given
parent
.
Constructs a color dialog with the given
parent
and specified
initial
颜色。
PySide2.QtWidgets.QColorDialog.
ColorDialogOption
¶
This enum specifies various options that affect the look and feel of a color dialog.
|
常量 |
描述 |
|---|---|
|
QColorDialog.ShowAlphaChannel |
Allow the user to select the alpha component of a color. |
|
QColorDialog.NoButtons |
Don’t display OK and Cancel buttons. (Useful for “live dialogs”.) |
|
QColorDialog.DontUseNativeDialog |
Use Qt’s standard color dialog instead of the operating system native color dialog. |
另请参阅
options
setOption()
testOption()
windowModality()
PySide2.QtWidgets.QColorDialog.
colorSelected
(
color
)
¶
color
–
QColor
PySide2.QtWidgets.QColorDialog.
currentColor
(
)
¶
QColor
另请参阅
PySide2.QtWidgets.QColorDialog.
currentColorChanged
(
color
)
¶
color
–
QColor
PySide2.QtWidgets.QColorDialog.
customColor
(
index
)
¶
index
–
int
QColor
Returns the custom color at the given
index
作为
QColor
值。
另请参阅
PySide2.QtWidgets.QColorDialog.
customCount
(
)
¶
int
Returns the number of custom colors supported by
QColorDialog
. All color dialogs share the same custom colors.
PySide2.QtWidgets.QColorDialog.
getColor
(
[
initial=Qt.white
[
,
parent=None
[
,
title=""
[
,
options=QColorDialog.ColorDialogOptions()
]
]
]
]
)
¶
initial
–
QColor
parent
–
QWidget
title – unicode
options
–
ColorDialogOptions
QColor
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
isValid()
) color if the user cancels the dialog.
options
argument allows you to customize the dialog.
PySide2.QtWidgets.QColorDialog.
open
(
receiver
,
member
)
¶
receiver
–
QObject
member – str
打开对话框并连接其
colorSelected()
signal to the slot specified by
receiver
and
member
.
信号将断开槽连接,当对话框被关闭时。
PySide2.QtWidgets.QColorDialog.
options
(
)
¶
ColorDialogOptions
另请参阅
PySide2.QtWidgets.QColorDialog.
selectedColor
(
)
¶
QColor
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.
PySide2.QtWidgets.QColorDialog.
setCurrentColor
(
color
)
¶
color
–
QColor
另请参阅
PySide2.QtWidgets.QColorDialog.
setCustomColor
(
index
,
color
)
¶
index
–
int
color
–
QColor
Sets the custom color at
index
到
QColor
color
值。
注意
This function does not apply to the Native Color Dialog on the macOS platform. If you still require this function, use the
DontUseNativeDialog
选项。
另请参阅
PySide2.QtWidgets.QColorDialog.
setOption
(
option
[
,
on=true
]
)
¶
option
–
ColorDialogOption
on
–
bool
设置给定
option
to be enabled if
on
is true; otherwise, clears the given
option
.
另请参阅
options
testOption()
PySide2.QtWidgets.QColorDialog.
setOptions
(
options
)
¶
options
–
ColorDialogOptions
另请参阅
PySide2.QtWidgets.QColorDialog.
setStandardColor
(
index
,
color
)
¶
index
–
int
color
–
QColor
Sets the standard color at
index
到
QColor
color
值。
注意
This function does not apply to the Native Color Dialog on the macOS platform. If you still require this function, use the
DontUseNativeDialog
选项。
另请参阅
PySide2.QtWidgets.QColorDialog.
standardColor
(
index
)
¶
index
–
int
QColor
Returns the standard color at the given
index
作为
QColor
值。
另请参阅
PySide2.QtWidgets.QColorDialog.
testOption
(
option
)
¶
option
–
ColorDialogOption
bool
返回
true
若给定
option
被启用;否则,返回 false。
另请参阅
options
setOption()