Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Wt (web toolkit)

From Wikipedia, the free encyclopedia
(Redirected fromWt – Web toolkit)
C++ web application framework
Wt
Original authorEmweb
Initial release1.0.0 / December 2005; 20 years ago (2005-12)
Stable release
4.10.4 / March 6, 2024; 23 months ago (2024-03-06)[1]
Written inC++
Operating systemCross-platform
TypeWeb framework
LicenseDual-licensed:
Websitewww.webtoolkit.eu/wt
Repositorygithub.com/emweb/wt

Wt (pronounced"witty") is anopen-sourcewidget-centricweb framework for theC++ programming language. It has anAPI resembling that ofQt framework (although it was developed with Boost, and is incompatible when mixed with Qt), also using a widget-tree and anevent-drivensignal/slot system.[3]

The Wt's design goal is to benefit from thestatefulcomponent model used in desktop-applications APIs, applied toweb development—instead of the traditionalMVC (model–view–controller) design pattern. So rather than using MVC at the level of aweb page, it is pushed to the level of individual components.[4]

While thelibrary uses a desktopsoftware development process, it does support someweb-specific features, including:

One of the unique features of Wt is its abstraction layer of the browserrendering model. The library usesAjax for communicating with browsers compatible with it, while using plainHTML-form post-backs for otheruser agents. Using a progressive bootstrap-method, theuser interface is rendered as a plain HTMLdocument first, then, provided its support in browser, it is automatically upgraded to useAjax for increased interactivity. In this way, Wt is by definition:

Because of the popularity ofC/C++ inembedded system environments, Wt is often used in such devices and (as a consequence) has been highly optimized forperformance.

Major features

[edit]

For a more detailed overview, see the Features section of official website.

Code example

[edit]

The"Hello, World!" program in Wt:

#include<Wt/WApplication.h>#include<Wt/WBreak.h>#include<Wt/WContainerWidget.h>#include<Wt/WLineEdit.h>#include<Wt/WPushButton.h>#include<Wt/WText.h>/* * A simple hello world application class which demonstrates how to react * to events, read input, and give feed-back. */classHelloApplication:publicWt::WApplication{public:HelloApplication(constWt::WEnvironment&env);private:Wt::WLineEdit*nameEdit_;Wt::WText*greeting_;voidgreet();};/* * The env argument contains information about the new session, and * the initial request. It must be passed to the WApplication * constructor so it is typically also an argument for your custom * application constructor.*/HelloApplication::HelloApplication(constWt::WEnvironment&env):WApplication(env){setTitle("Hello world");// application titleroot()->addNew<Wt::WText>("Your name, please ? ");// show some textnameEdit_=root()->addNew<Wt::WLineEdit>();// allow text inputnameEdit_->setFocus();// give focusautobutton=root()->addNew<Wt::WPushButton>("Greet me.");// create a buttonbutton->setMargin(5,Wt::Side::Left);// add 5 pixels marginroot()->addNew<Wt::WBreak>();// insert a line breakgreeting_=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, e.g. 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";});}voidHelloApplication::greet(){/*   * Update the text, using text input into the nameEdit_ field.   */greeting_->setText("Hello there, "+nameEdit_->text());}intmain(intargc,char**argv){/*   * Your main method may 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. That function is executed when a new user surfs   * to the Wt application, and after the library has negotiated browser   * support. The function should return a newly instantiated application   * object.   */returnWt::WRun(argc,argv,[](constWt::WEnvironment&env){/*     * You could read information from the environment to decide whether     * the user has permission to start a new application     */returnstd::make_unique<HelloApplication>(env);});}

See also

[edit]

References

[edit]
  1. ^"Wt: Release notes".www.webtoolkit.eu. Retrieved2024-07-10.
  2. ^"wt/LICENSE".GitHub. Retrieved2024-12-30.
  3. ^Dumon, Wim; Deforche, Koen (February 11, 2008)."Wt: A Web Toolkit".Dr. Dobb's Journal. RetrievedJanuary 24, 2017.
  4. ^Volkman, Victor (June 6, 2008)."Wt: C++ Web Toolkit Library Lets You Write Scripting-Independent Web Apps".QuinStreet. Archived fromthe original on March 21, 2012. RetrievedJanuary 24, 2017.

External links

[edit]
.NET
C++
ColdFusion
Common Lisp
Haskell
Java
JavaScript
Back end
Server-side
Full-stack
Front end
Client-side
Perl
PHP
Python
Ruby
Rust
Scala
Smalltalk
Other languages
Retrieved from "https://en.wikipedia.org/w/index.php?title=Wt_(web_toolkit)&oldid=1338978453"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp