Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Major features  





2 Code example  





3 See also  





4 References  





5 External links  














Wt (web toolkit)






Deutsch
Italiano
 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


Wt
Original author(s)Emweb
Initial release1.0.0 / December 2005; 18 years ago (2005-12)
Stable release

4.10.0 / May 30, 2023; 13 months ago (2023-05-30)[1]

RepositoryWt Repository
Written inC++
Operating systemCross-platform
TypeWeb framework
LicenseDual-licensed:
  • Commercial License
  • Websitewww.webtoolkit.eu/wt

    Wt (pronounced "witty") is an open-source widget-centric web framework for the C++ programming language. It has an API resembling that of Qt framework (although it was developed with Boost, and is incompatible when mixed with Qt), also using a widget-tree and an event-driven signal/slot system.[2]

    The Wt's design goal is to benefit from the stateful component model used in desktop-applications APIs, applied to web development—instead of the 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.[3]

    While the library uses a desktop software development process, it does support some web-specific features, including:

    One of the unique features of Wt is its abstraction layer of the browser rendering model. The library uses Ajax for communicating with browsers compatible with it, while using plain HTML-form post-backs for other user agents. Using a progressive bootstrap-method, the user interface is rendered as a plain HTML document first, then, provided its support in browser, it is automatically upgraded to use Ajax for increased interactivity. In this way, Wt is by definition:

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

    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.
     */
    class HelloApplication : public Wt::WApplication
    {
    public:
      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 WApplication
     * constructor so it is typically 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, 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";
      });
    }
    
    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 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.
       */
      return Wt::WRun(argc, argv, [](const Wt::WEnvironment &env) {
        /*
         * You could read information from the environment to decide whether
         * the user has permission to start a new application
         */
        return std::make_unique<HelloApplication>(env);
      });
    }
    

    See also[edit]

    References[edit]

    1. ^ "Wt: Release notes". www.webtoolkit.eu. Retrieved 2022-04-20.
  • ^ Dumon, Wim; Deforche, Koen (February 11, 2008). "Wt: A Web Toolkit". Dr. Dobb's Journal. Retrieved January 24, 2017.
  • ^ Volkman, Victor (June 6, 2008). "Wt: C++ Web Toolkit Library Lets You Write Scripting-Independent Web Apps". QuinStreet. Retrieved January 24, 2017.
  • External links[edit]

    Official website Edit this at Wikidata


    Retrieved from "https://en.wikipedia.org/w/index.php?title=Wt_(web_toolkit)&oldid=1209738829"

    Categories: 
    Ajax (programming)
    Rich web application frameworks
    Web development software
    Web frameworks
    Web server software
    Hidden categories: 
    Articles with short description
    Short description is different from Wikidata
    Articles with example C++ code
     



    This page was last edited on 23 February 2024, at 10:02 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki