hello/hello.C

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2006 Wim Dumon
00003  *
00004  * See the LICENSE file for terms of use.
00005  */
00006 
00007 #include <WApplication>
00008 #include <WContainerWidget>
00009 #include <WText>
00010 #include <WPushButton>
00011 
00012 using namespace Wt;
00013 
00014 // This is the entry-point for a new session.
00015 //
00016 // This function is executed when a new user surfs to the Wt application,
00017 // and after the library has negotiated browser support. This function must
00018 // return a new WApplication object.
00019 
00020 WApplication *createApplication(const WEnvironment& env)
00021 {
00022   // Instantiate the Wt application.
00023   WApplication *appl = new WApplication(env);
00024 
00025   // Set application title
00026   appl->setTitle("Hello world!");
00027 
00028   // Widgets can be added to a parent by calling addWidget()...
00029   // WApplication::root() is a WContainerWidget that is associated with
00030   // the entire browser window.
00031   appl->root()->addWidget(new WText(L"<h1>Hello, World!</h1>"));
00032 
00033   // .. or by specifying a parent at construction
00034   WPushButton *Button = new WPushButton(L"Quit", appl->root());
00035 
00036   // React to user events using a signal/slot mechanism.
00037   Button->clicked.connect(SLOT(appl, WApplication::quit));
00038 
00039   return appl;
00040 }
00041 
00042 int main(int argc, char **argv)
00043 {
00044    return WRun(argc, argv, &createApplication);
00045 }
00046 

Generated on Sun Jul 1 19:37:23 2007 for Wt by doxygen 1.4.7