QtWui: Web User Interface for Qt

0.2

What is QtWui

QtWui is a module for Qt that enables you to write web applications just like you where writing a standard desktop GUI application with QtGui. It comes with a simple web server that runs the application. In the future it will also be possible to use an external web server that supports FastCGI.

Getting the sources

You can download the source package here: http://downloads.sourceforge.net/qtwui/qtwui-0.1.tar.gz

You can checkout latest SVN version:

svn co https://qtwui.svn.sourceforge.net/svnroot/qtwui qtwui

General principle

The idea behind QtWui is that each connected user opens a new session on the server and this session is like a standard application process on a desktop computer. Each sessin has a lifetime that can be configured. If no user action occurs before the end of the session lifetime, it is destroyed.

Internal machinery

qtwui-schema.png

The web server works with an application server (QwuiApplicationServer) that is in charge of creating applications instances for each new client (web browser).

When a client (web browser) connects to the server, a new application instance is created and a session ID is affected to it. All further communication between the client and the server use this session ID, refering always the same application instance within the server.

Each application instance is independant of the others. Modifying the widgets won't affect the other application instances.

You can chose between two different ways of handling client requests:

If the application cannot provide any html code for the given URL, the request is forwarded to a file resource provider who will check if a file on the disk corresponds to the request and than will transmit it.

QtWui makes use of the AJAX technology to communicate between the client and the server. All the client AJAX machinery is provided by Prototype Javascript Framework (http://www.prototypejs.org/).

Web widgets

QtWui doesn't provide many web widgets (webgets) for the moment:

Example

Here is the traditionnal "Hello World" example:

//
// the traditionnal main function only starts the application server.
//
int main(int argc, char** argv)
{
    QCoreApplication app(argc, argv);
    QwuiApplicationServer webAppServer(webMain);
    webAppServer.setBuiltInServerPort(8888);
    webAppServer.exec();
    return app.exec();
}

//
// This is the main function executed by the application server for each new session.
//
QwuiApplication* webMain(const QString& sessionId, const QStringList& args)
{
    Q_UNUSED(args);

    QwuiApplication* webApp = new QwuiApplication(sessionId);
    QwuiMainWebget* mw = new QwuiMainWebget(NULL, "mw");
    mw->setTitle("QtWui Test");
    QwuiLabel* helloWorld = new QwuiLabel(mw, "helloWorld");
    webApp->setMainWebget(helloWorld);
    helloWorld->setText("Hello World !");
    return webApp;
}

Installing

QtWui can be built like a standard Qt program: with qmake and make. The sources come with a simple demo: a hangman game. It is built with the QtWui sources. Go to the folder where you uncompressed the source archive and follow the these steps:

The run_hangman script starts the server on the port 8888. edit the script to change the port. Then start a web browser and go to the http://localhost:8888 page to try the game.

Future

There are many feature missing in QtWui to make it a usable web application framework. The main missing things are:

Contact

Main developer: Eric ALBER (eric DOT alber AT gmail DOT com)

Help is welcome!

Generated on Fri Jun 4 01:18:58 2010 for QtWui : Web User Interfaces for Qt by  doxygen 1.6.3