Wt (web toolkit)

Wt (pronounced “witty”) is an open-source widget-centric web framework for the C ++ programming language. It has an API resembling that of the Qt framework, which uses a widget-tree and an event-driven signal / slot system. The Wt’s design is used by the state of the model used in desktop-applications APIs, applied to the web-development of traditional MVC (model-view-controller) design pattern. So rather than using MVC at the level of a web page, it is pushed to the level of individual components. While the library uses a desktop software development process, it does support some web-specific features, including:

The “Hello, World!” program in Wt: <source lang = “cpp”> * to events, read input, and give feedback. class HelloApplication: public Wt :: public WApplication: HelloApplication (const Wt :: WEnvironment & env); private: Wt :: WLineEdit * nameEdit_; Wt :: WText * greeting_; void greet; * The env argument contains information about the new session, and * the initial request. It must be passed to the application * constructor so it is also an argument for your custom * application constructor. HelloApplication :: HelloApplication (const Wt :: WEnvironment & env): WApplication (env) setTitle (“Hello world”); // application title root-> addNew <Wt :: WText> (“Your name, please?”); // show some text nameEdit_ = root-> addNew <Wt :: WLineEdit>; // allow text input nameEdit _-> setFocus; // give focus auto button = root-> addNew <Wt :: WPushButton> (“Greet me.”); // create a button button-> setMargin (5, Wt :: Side :: Left); // add 5 pixels margin root-> addNew <Wt :: WBreak>; // insert a line break greeting_ = root-> addNew <Wt :: WText>; // empty text * Connect signals with slots * – simple Wt-way: specify object and method button-> clicked.connect (this, & HelloApplication :: greet); * – using an arbitrary function object, eg useful to bind * values ​​with std :: bind to the resulting method call nameEdit _-> enterPressed.connect (std :: bind (& HelloApplication :: greet, this)); * – using a lambda: button-> clicked.connect ([=] {std :: cerr << “Hello there,” << nameEdit _-> text << “\ n”; void HelloApplication :: greet * Update the text, using text input into the nameEdit_field. greeting _-> setText (“Hello there,” + nameEdit _-> text); int main (int argc, char ** argv) * Your main method can set up some shared resources, but should then start the server application (FastCGI or httpd) that starts listening * for requests, and handles all of the application life cycles . * The last argument to WRun specifies the function that will instantiate * new application objects. This function is executed when a new user surfs the application, and after the library has negotiated browser support. The function should return a newly instantiated application * object. return Wt :: WRun (argc, argv, [] (const Wt :: WEnvironment &

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright embedder.eu 2018
Shale theme by Siteturner