Qt:Документация 4.3.2/qcheckbox

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

QCheckBox Class Reference
[модуль QtGui ]

The QCheckBox widget provides a checkbox with a text label. More...

 #include <QCheckBox>

Inherits QAbstractButton.

Свойства

  • 11 свойства унаследованных от QAbstractButton
  • 56 свойства унаследованных от QWidget
  • 1 свойство унаследованное от QObject

Открытые функции

  • 21 открытых функций унаследованных от QAbstractButton
  • 201 открытых функций унаследованных от QWidget
  • 29 открытых функций унаследованных от QObject
  • 12 открытых функций унаследованных от QPaintDevice

Сигналы

  • 4 сигнала унаследованных от QAbstractButton
  • 1 сигнал унаследованный от QWidget
  • 1 сигнал унаследованный от QObject

Защищенные функции

  • 3 защищенных функций унаследованных от QAbstractButton
  • 38 защищенных функций унаследованных от QWidget
  • 7 защищенных функций унаследованных от QObject
  • 1 защищенная функция унаследованна от QPaintDevice

Дополнительные унаследованные члены

  • 5 открытых слотов унаследованных от QAbstractButton
  • 19 открытых слотов унаследованных от QWidget
  • 1 открытый слот унаследованный от QObject
  • 4 статических открытых члена унаследованных от QWidget
  • 5 статических открытых члена унаследованных от QObject
  • 1 защищенный слот унаследованный от QWidget

Подробное описание

The QCheckBox widget provides a checkbox with a text label.

A QCheckBox is 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, but different types of behavior can be implemented.

A QButtonGroup can be used to group check buttons visually.

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 use isChecked() to query whether or not a checkbox is checked.

In addition to the usual checked and unchecked states, QCheckBox optionally 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 with setTristate(), and use checkState() to query the current toggle state.

Just like QPushButton, a checkbox displays text, and optionally a small icon. The icon is set with setIcon(). The text can be set in the constructor or with setText(). A shortcut key can be specified by preceding the preferred character with an ampersand. For example:

 QCheckBox *checkbox = new QCheckBox("C&amp;ase sensitive", this);

In this example the shortcut is Alt+A. See the QShortcut documentation for details (to display an actual ampersand, use '&&').

Important inherited functions: text(), setText(), text(), pixmap(), setPixmap(), accel(), setAccel(), isToggleButton(), setDown(), isDown(), isOn(), checkState(), autoRepeat(), isExclusiveToggle(), group(), setAutoRepeat(), toggle(), pressed(), released(), clicked(), toggled(), checkState(), and stateChanged().


center A checkbox shown in the Macintosh widget style.
center A checkbox shown in the Windows XP widget style.
Файл:Plastique-checkbox.png A checkbox shown in the Plastique widget style.

See also QAbstractButton, QRadioButton, and GUI Design Handbook: Check Box.


Описание свойств

tristate : bool

This property holds whether the checkbox is a tri-state checkbox.

The default is false; i.e. the checkbox has only two states.

Функции доступа:

  • bool isTristate () const
  • void setTristate ( bool y = true )

Описание функций-членов

QCheckBox::QCheckBox ( QWidget * parent = 0 )

Constructs a checkbox with the given parent, but with no text.

The parent argument is passed on to the QAbstractButton constructor.

QCheckBox::QCheckBox ( const QString & text, QWidget * parent = 0 )

Constructs a checkbox with the given parent and text.

The parent argument is passed on to the QAbstractButton constructor.

Qt::CheckState QCheckBox::checkState () const

Returns the check box's check state.

See also setCheckState() and Qt::CheckState.

void QCheckBox::initStyleOption ( QStyleOptionButton * option ) const [protected]

Initialize option with the values from this QCheckBox. This method is useful for subclasses when they need a QStyleOptionButton, but don't want to fill in all the information themselves.

See also QStyleOption::initFrom().

void QCheckBox::setCheckState ( Qt::CheckState state )

Sets the check box's check state to state.

See also checkState() and Qt::CheckState.

void QCheckBox::stateChanged ( int state ) [signal]

This signal is emitted whenever the check box's state changes, i.e. whenever the user checks or unchecks it.

state contains the check box's new ToggleState.


Copyright © 2007 Trolltech Trademarks
Qt 4.3.2