How to Use qtcreator to develop the wt (C ++ Web Toolkit) Program

Source: Internet
Author: User

What is wt? I don't want to explain it. If you are interested, you can go to NLP (I am afraid to compliment wt's official materials) and use qtcreator to develop wt.

 

Start with a simple helloword.

Pro File

 

#-------------------------------------------------

#

# Project created by qtcreator 2010-11-18t12: 10: 20

#

#-------------------------------------------------

Qt-= Core

Qt-= Gui

Target = Hello. WT

Libs + =-L/usr/local/lib-lwt-lwthttp

Config + = console

Config-= app_bundle

Template = app

Sources + = Main. cpp

Main. CPP # include <WT/wapplication> # include <WT/wbreak> # include <WT/wcontainerwidget> # include <WT/wlineedit> # include <WT/wpushbutton> # include <WT /wtext> # include <boost/version. HPP> using namespace wt;/** a simple hello World application class which demonstrates how to react * to events, read input, and give feed-back. */class helloapplication: Public wapplication {public: helloapplication (const wenviro Nment & env); Private: wlineedit * nameedit _; 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 wenvironment & env): wapplication (ENV) {settitle ("hello ");// Application title root ()-> addwidget (New wtext ("Your name, please? "); // Show some text nameedit _ = new wlineedit (root (); // allow text input nameedit _-> setfocus (); // give focus wpushbutton * B = new wpushbutton ("greet me. ", root (); // create a button B-> setmargin (5, left); // Add 5 pixels margin root () -> addwidget (New wbreak (); // insert a line break greeting _ = new wtext (root ()); // empty text/** connect signals with slots **-simple wt-way */B-> clicked (). connect (this, & helloapplication: Greet);/**-using an arbitrary function object (binding values with boost: BIND ()) */nameedit _-> enterpressed (). connect (boost: BIND (& helloapplication: Greet, this);} void helloapplication: Greet () {/** update the text, using text input into the nameedit _ field. */greeting _-> settext ("Hello there," + nameedit _-> text ();} wapplication * createapplication (const wenvironment & env) {/** you cocould read information from the environment to decide whether * the user has permission to start a new application */return New helloapplication (ENV);} int main (INT argc, char ** argv) {/** your main method may set up some shared resources, but shoshould 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 shoshould return a newly instantiated application * object. */return wrun (argc, argv, & createapplication );} this is the helloword project file, which cannot be run now. Then, add the wt shared library address in the runtime environment. Now open the browser and enter 0.0.0.0: 8080. Click "compile" to run successfully, in this way, we don't know that the development efficiency is n times higher. Well, we don't know when wt will become popular in China.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.