Project

General

Profile

Bug #2193 ยป signals2bug.cpp

Anonymous, 09/08/2013 03:35 PM

 
#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WText>
#include <Wt/WDateTime>
#include <Wt/WTimer>
#include <Wt/WPushButton>

using namespace Wt;
using namespace std;

class SampleApp : public WApplication
{
public:
SampleApp(const WEnvironment& env);
WText *second;
WText *third;
void setSecondText() { second->setText("Second!"); }
};

SampleApp::SampleApp(const WEnvironment& env)
: WApplication(env)
{
WText *first = new WText(root());
second = new WText(root());
third = new WText(root());
WTimer::singleShot(1000, [=](WMouseEvent){ first->setText("First!"); });
WTimer::singleShot(1000, boost::bind(&SampleApp::setSecondText, this));
auto timer = new WTimer(this);
timer->setInterval(500);
timer->timeout().connect([=](WMouseEvent) { third->setText(WDateTime::currentDateTime().toString()); } );
timer->start();
}


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

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