Wt: Wt::WRadioButton Class Reference

Wt 3.3.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Member Functions
Wt::WRadioButton Class Reference

A user control that represents a radio button. More...

`#include <Wt/WRadioButton>`

Inheritance diagram for Wt::WRadioButton:
[legend]

List of all members.

## Public Member Functions
| WRadioButton (WContainerWidget *parent=0)
| Creates an unchecked radio button with empty label and optional parent.
| WRadioButton (const WString &text, WContainerWidget *parent=0)
| Creates an unchecked radio button with given text and optional parent.
| ~WRadioButton ()
| Destructor.
WButtonGroup * | group () const
| Returns the button group.

## Detailed Description

A user control that represents a radio button.

Use a WButtonGroup to group together radio buttons that reflect options that are mutually exclusive.

Usage example:

     enum Vote { Republican = 1, Democrate = 2, NoVote = 10 };

     // use a group box as widget container for 3 radio buttons, with a title
     Wt::WGroupBox *container = new Wt::WGroupBox("USA elections vote");

     // use a button group to logically group the 3 options
     Wt::WButtonGroup *group = new Wt::WButtonGroup(this);

     Wt::WRadioButton *button;
     button = new Wt::WRadioButton("I voted Republican", container);
     new Wt::WBreak(container);
     group->addButton(button, Republican);

     button = new Wt::WRadioButton("I voted Democrat", container);
     new Wt::WBreak(container);
     group->addButton(button, Democrate);

     button = new Wt::WRadioButton("I didn't vote", container);
     new Wt::WBreak(container);
     group->addButton(button, NoVote);

     group->setCheckedButton(group->button(NoVote));

WRadioButton is an inline widget.

### CSS

This widget corresponds to the HTML `<input type="radio">` tag. When a label is specified, the input element is nested in a `<label>`.

This widget does not provide styling, and can be styled using inline or external CSS as appropriate.

See also:
  WAbstractToggleButton, WButtonGroup

## Member Function Documentation

WButtonGroup* Wt::WRadioButton::group | ( |  | ) | const

Returns the button group.

Returns the button group to which this button belongs.

See also:
  WButtonGroup::addButton(WRadioButton *, int)

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator