|
Wt examples
3.3.5
|
Public Member Functions | |
| HelloApplication (const WEnvironment &env) | |
Private Member Functions | |
| void | greet () |
Private Attributes | |
| WLineEdit * | nameEdit_ |
| WText * | greeting_ |
| HelloApplication::HelloApplication | ( | const WEnvironment & | env | ) |
Definition at line 41 of file hello.C.
: WApplication(env)
{
setTitle("Hello world"); // application title
root()->addWidget(new WText("Your name, please ? ")); // show some text
nameEdit_ = new WLineEdit(root()); // allow text input
nameEdit_->setFocus(); // give focus
WPushButton *button
= new WPushButton("Greet me.", root()); // create a button
button->setMargin(5, Left); // add 5 pixels margin
root()->addWidget(new WBreak()); // insert a line break
greeting_ = new WText(root()); // empty text
/*
* Connect signals with slots
*
* - simple Wt-way
*/
button->clicked().connect(this, &HelloApplication::greet);
/*
* - using an arbitrary function object (binding values with boost::bind())
*/
nameEdit_->enterPressed().connect
(boost::bind(&HelloApplication::greet, this));
/*
* - using a c++0x lambda:
*/
// button->clicked().connect(std::bind([=]() {
// greeting_->setText("Hello there, " + nameEdit_->text());
// }));
}
| void HelloApplication::greet | ( | ) | [private] |
WText* HelloApplication::greeting_ [private] |
WLineEdit* HelloApplication::nameEdit_ [private] |
1.7.6.1