#include #include #include #include #include #include #include class HelloApplication : public Wt::WApplication { public: HelloApplication(const Wt::WEnvironment& env); private: Wt::WLineEdit *nameEdit_; Wt::WText *greeting_; }; HelloApplication::HelloApplication(const Wt::WEnvironment& env) : Wt::WApplication(env) { //Set the theme auto theme = std::make_shared(); theme->setVersion(Wt::BootstrapVersion::v3); wApp->setTheme(theme); setTitle("Hello world"); auto text = std::make_unique("Your name, please? "); //add bootstrap style to widget text->addStyleClass("label label-primary"); root()->addWidget(std::move(text)); nameEdit_ = root()->addWidget(std::make_unique()); Wt::WPushButton *button = root()->addWidget(std::make_unique("Greet me.")); button->addStyleClass("btn btn-success"); root()->addWidget(std::make_unique()); greeting_ = root()->addWidget(std::make_unique()); auto greet = [this] { greeting_->setText("Hello there, " + nameEdit_->text()); }; button->clicked().connect(greet); } int main(int argc, char **argv) { return Wt::WRun(argc, argv, [](const Wt::WEnvironment& env) { return std::make_unique(env); }); }