Wt examples  3.2.1
Public Member Functions | Private Member Functions | Private Attributes
HelloApplication Class Reference
Inheritance diagram for HelloApplication:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 HelloApplication (const WEnvironment &env)

Private Member Functions

void greet ()

Private Attributes

WLineEditnameEdit_
WTextgreeting_

Detailed Description

Definition at line 23 of file hello.C.


Constructor & Destructor Documentation

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:
   */
  // b->clicked().connect(std::bind([=]() { 
  //       greeting_->setText("Hello there, " + nameEdit_->text());
  // }));
}

Member Function Documentation

void HelloApplication::greet ( ) [private]

Definition at line 79 of file hello.C.

{
  /*
   * Update the text, using text input into the nameEdit_ field.
   */
  greeting_->setText("Hello there, " + nameEdit_->text());
}

Member Data Documentation

Definition at line 30 of file hello.C.

Definition at line 29 of file hello.C.


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

Generated on Fri Mar 30 2012 for the C++ Web Toolkit (Wt) by doxygen 1.7.5.1