def
checkState
()
def
initStyleOption
(option)
def
isTristate
()
def
setCheckState
(state)
def
setTristate
([y=true])
def
stateChanged
(arg__1)
![]()
A
QCheckBoxis an option button that can be switched on (checked) or off (unchecked). Checkboxes are typically used to represent features in an application that can be enabled or disabled without affecting others. Different types of behavior can be implemented. For example, aQButtonGroupcan be used to group check buttons logically, allowing exclusive checkboxes. However,QButtonGroupdoes not provide any visual representation.The image below further illustrates the differences between exclusive and non-exclusive checkboxes.
![]()
![]()
Whenever a checkbox is checked or cleared, it emits the signal
stateChanged(). Connect to this signal if you want to trigger an action each time the checkbox changes state. You can useisChecked()to query whether or not a checkbox is checked.In addition to the usual checked and unchecked states,
QCheckBoxoptionally provides a third state to indicate “no change”. This is useful whenever you need to give the user the option of neither checking nor unchecking a checkbox. If you need this third state, enable it withsetTristate(), and usecheckState()to query the current toggle state.就像
QPushButton, a checkbox displays text, and optionally a small icon. The icon is set withsetIcon(). The text can be set in the constructor or withsetText(). A shortcut key can be specified by preceding the preferred character with an ampersand. For example:checkbox = QCheckBox("C&ase sensitive", self)In this example, the shortcut is Alt+A 。见
QShortcutdocumentation for details. To display an actual ampersand, use ‘&&’.重要继承函数:
text(),setText(),text(), pixmap(), setPixmap(), accel(), setAccel(), isToggleButton(),setDown(),isDown(), isOn(),checkState(),autoRepeat(), isExclusiveToggle(),group(),setAutoRepeat(),toggle(),pressed(),released(),clicked(),toggled(),checkState(),和stateChanged().
QCheckBox
(
[
parent=None
]
)
¶
QCheckBox(text[, parent=None])
- param parent
- param text
unicode
Constructs a checkbox with the given
parent
, but with no text.
parent
被传递给
QAbstractButton
构造函数。
Constructs a checkbox with the given
parent
and
text
.
parent
被传递给
QAbstractButton
构造函数。
PySide2.QtWidgets.QCheckBox.
checkState
(
)
¶
CheckState
Returns the checkbox’s check state. If you do not need tristate support, you can also use
isChecked()
, which returns a boolean.
另请参阅
setCheckState()
CheckState
PySide2.QtWidgets.QCheckBox.
initStyleOption
(
option
)
¶
option
–
QStyleOptionButton
初始化
option
采用值来自此
QCheckBox
. This method is useful for subclasses that require a
QStyleOptionButton
, but do not want to fill in all the information themselves.
另请参阅
PySide2.QtWidgets.QCheckBox.
isTristate
(
)
¶
bool
PySide2.QtWidgets.QCheckBox.
setCheckState
(
state
)
¶
state
–
CheckState
Sets the checkbox’s check state to
state
. If you do not need tristate support, you can also use
setChecked()
, which takes a boolean.
另请参阅
checkState()
CheckState
PySide2.QtWidgets.QCheckBox.
setTristate
(
[
y=true
]
)
¶
y
–
bool
另请参阅
PySide2.QtWidgets.QCheckBox.
stateChanged
(
arg__1
)
¶
arg__1
–
int