Project

General

Profile

Bug #1225 ยป hello.C

Pieter Libin, 04/05/2012 04:03 PM

 
/*
* Copyright (C) 2008 Emweb bvba, Heverlee, Belgium.
*
* See the LICENSE file for terms of use.
*/

#include <Wt/WApplication>
#include <Wt/WVBoxLayout>
#include <Wt/WText>
#include <Wt/WPushButton>
#include <Wt/WContainerWidget>

#include <string>

using namespace Wt;

class HelloApplication : public WApplication
{
public:
HelloApplication(const WEnvironment& env);

void showText2();

WText *t2_;
};

HelloApplication::HelloApplication(const WEnvironment& env)
: WApplication(env)
{
WVBoxLayout *l = new WVBoxLayout();
root()->setLayout(l);

WText *t1 = new WText("text 1");
l->addWidget(t1, 0);
t2_ = new WText("text 2");
t2_->setHidden(true);
l->addWidget(t2_, 0);
WPushButton *b = new WPushButton("show text 2");
b->clicked().connect(this, &HelloApplication::showText2);
l->addWidget(b, 0);
}

void HelloApplication::showText2()
{
t2_->setHidden(false);
}

WApplication *createApplication(const WEnvironment& env)
{
return new HelloApplication(env);
}

int main(int argc, char **argv)
{
return WRun(argc, argv, &createApplication);
}

    (1-1/1)