Wt examples  3.3.6
Public Member Functions | Private Member Functions | Private Attributes | List of all members
HelloApplication Class Reference
Inheritance diagram for HelloApplication:
Inheritance graph
[legend]

Public Member Functions

 HelloApplication (const WEnvironment &env)
 

Private Member Functions

void greet ()
 

Private Attributes

WLineEdit * nameEdit_
 
WText * greeting_
 

Detailed Description

Definition at line 23 of file hello.C.

Constructor & Destructor Documentation

§ HelloApplication()

HelloApplication::HelloApplication ( const WEnvironment &  env)

Definition at line 41 of file hello.C.

42  : WApplication(env)
43 {
44  setTitle("Hello world"); // application title
45 
46  root()->addWidget(new WText("Your name, please ? ")); // show some text
47  nameEdit_ = new WLineEdit(root()); // allow text input
48  nameEdit_->setFocus(); // give focus
49 
50  WPushButton *button
51  = new WPushButton("Greet me.", root()); // create a button
52  button->setMargin(5, Left); // add 5 pixels margin
53 
54  root()->addWidget(new WBreak()); // insert a line break
55 
56  greeting_ = new WText(root()); // empty text
57 
58  /*
59  * Connect signals with slots
60  *
61  * - simple Wt-way
62  */
63  button->clicked().connect(this, &HelloApplication::greet);
64 
65  /*
66  * - using an arbitrary function object (binding values with boost::bind())
67  */
68  nameEdit_->enterPressed().connect
69  (boost::bind(&HelloApplication::greet, this));
70 
71  /*
72  * - using a c++0x lambda:
73  */
74  // button->clicked().connect(std::bind([=]() {
75  // greeting_->setText("Hello there, " + nameEdit_->text());
76  // }));
77 }
WLineEdit * nameEdit_
Definition: hello.C:29
WText * greeting_
Definition: hello.C:30
void greet()
Definition: hello.C:79

Member Function Documentation

§ greet()

void HelloApplication::greet ( )
private

Definition at line 79 of file hello.C.

80 {
81  /*
82  * Update the text, using text input into the nameEdit_ field.
83  */
84  greeting_->setText("Hello there, " + nameEdit_->text());
85 }
WLineEdit * nameEdit_
Definition: hello.C:29
WText * greeting_
Definition: hello.C:30

Member Data Documentation

§ greeting_

WText* HelloApplication::greeting_
private

Definition at line 30 of file hello.C.

§ nameEdit_

WLineEdit* HelloApplication::nameEdit_
private

Definition at line 29 of file hello.C.


The documentation for this class was generated from the following file:

Generated on Thu Jan 12 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.12