A user control that represents a radio button. More...
#include <Wt/WRadioButton>
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. |
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.
This widget corresponds to the HTML <input type="radio">
tag. Depending on whether a text is included, it may be nested in a <span>
tag which also includes a rendered WLabel. This widget does not provide styling, and can be styled using inline or external CSS as appropriate.
WButtonGroup* Wt::WRadioButton::group | ( | ) | const [inline] |
Returns the button group.
Returns the button group to which this button belongs.