How to create a custom GUI Server for QT applications

In a desktop PC, running a QT application is straight forward, just compile the application then execute it. So you will not notice the behind the scene tasks done.

To run Qt Linux applications, we must first start one process to act as a GUI server. Most of the Linux distributions run X11 as the default GUI server. X11 runs in the background. Once the X11 is started it takes care of framebuffer (the memory area associated with the video display) and becomes a server. The server is responsible for allocating screen regions to clients and for generating mouse and keyboard events.

When you launch a GUI application (client), the client applications communicate with the GUI server using shared memory and Unix pipes. The clients draw themselves into the Linux framebuffer and are responsible for painting their own window decorations, etc.

But in embedded such as mobile, PDA, car infotainment, etc., generally will have slower processors, less permanent storage (flash memory or hard disk), less memory, and smaller displays than desktop computers. In such case QT can come into rescue.

Unlike Qt/X11, it does not need the X Window System; instead, it implements its own window system QWS (Qt Window System), enabling significant storage and memory savings. To reduce its memory footprint even more, Qt/Embedded Linux can be recompiled to exclude unused features. If the applications and components used on a device are known in advance, they can be compiled together into a single executable that links statically against the Qt/Embedded Linux libraries.

Qt draws directly to the Linux framebuffer Make sure the /dev/fb0 device have write permissions to access the framebuffer, otherwise it may though permission denied errors.

  • Any Qt/Embedded Linux application can become a server by specifying -qws on its command line.
  • $ ./qt_app –qws
  • Passing QApplication::GuiServer as the third parameter to the QApplication constructor will make the application to run in server mode.
  • QApplication app(argc, &argv0, QApplication::GuiServer);

    If you are running only one application then simply passing -qws or else if you are planning to run multiple GUI application then passing QApplication::GuiServer to QApplication constructor is good option.

    Else if there are more than one QT application to be executed at a time, then having a QT GUI server running in the background and multiple clients connecting to that server and using the framebuffer is better choice. where the server will take care of sharing the desktop between devices.

    Here is a simple QT GUI server code.


    int main(int argc, char *argv[])
      // Start the qtapp thread in server mode
      QApplication app(argc, argv, QApplication::GuiServer);
      return app.exec();

    Compile this application and execute it in background in the target board

    $ ./qt_server &

    Our QT GUI server is running in the background and ready to service the QT clients, So now start you QT app, may be a simple hello app to test.

    All the best.

    3 thoughts on “How to create a custom GUI Server for QT applications

    1. Hello sir,
      I am a student working on Qt project for creating an app for gathering large scale information in Handheld devices.
      I have completed the following:
      2)XML parser for the input
      3)HTTP program for downloading something from a server

      Please let me know what should I do to connect my app with the server(JSP). I am also finding a lot of problem in Networking part.
      Thank you.

      Raju Kumar Jaiswal

      1. Hi,

        I am not an expert in QT. Refer the QT documentation in (, And raise your question in QT forum & mailing where you will likely to get the answer, since forums and mailing lists are where place where you can find people with expertise.

        All the best.

    Leave a Reply

    Fill in your details below or click an icon to log in: Logo

    You are commenting using your account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s