Friday, August 13, 2010

WxWidget/GTK vs QT


wxWidgets can be downloaded at
and current stable build is available at

wxWidgets not only works for C++, but also has bindings for python, perl, java, lua, eiffel, C# (.NET), basic, ruby and even javascript (see General Information for bindings).
It is one of the most complete GUI toolkits. There are many utility classes.
There is a lot of documentation (though a bit fragmented in places).
Free for personal and commercial use.
Whenever possible, wxWidgets uses the native platform SDK. This means that a program compiled on Windows will have the look and feel of a Windows program, and when compiled on a Linux machine, it will get the look and feel of a Linux program.
A positive side effect is that wxWidgets is thus more likely to look, behave and feel native - sometimes including native features for free (e.g. possibility to have spellchecking built-in in all text areas on OS X).
A negative side effect of this is that it is more likely that the behaviour is different between platforms; toolkits where widgets are lightweight lose some of the native aspect but also minimize platform-specific code (hence minimizing the risk of different behaviour from platform to platform and also minimizing the risk of platform-specific bugs). Concentrating on native looks also mean wx may not be best suited for applications that want a customized look instead of the system's theme.

Windows Build extract everything under


Go to C:\wxWidgets-2.8.11\build\msw

open wx.dsw with Visual Studio 2008. Visual Studio will then ask you if
you want to convert the Visual Studio 6 project to visual studio vcproj.
Select yes to all. By default wxWidgets will target win32 platform but
you can add x64 platform.

All lib will be generated under


wxWidget works well with GTK+ because GTK is one of the choice to build wxWidget on Linux.

GTK+, originally the Gimp toolkit, is a LGPL C-language GUI library for Unix systems.
It has been ported to Windows, VMS, and other systems (MacOS X currently possible through Apple's, native version in development) using the same API. However, primary development and focus is for Unix, with multi-platform development mostly as an afterthought.
GTK+ is the primary library used to construct user interfaces in GNOME.
Unlike wxWidgets, GTK+ supports C (and there is a C++ wrapper called GTKMM, )
The API is quite well developed, and includes safe casting and other things; but C++ has these built in.
It's built on top of glib, a general-purpose library (similar in some ways to the C++ STL -- it provides a few data structures, functions to help memory management, etc).
It looks the same on all platforms, except Windows XP, where it tries (with some success) to get Windows' native look and feel with the Wimp theme, which uses UxTheme. However, it's still very much a Unix library.

Building GTK+ on Windows requires MinGW and MSys which might mot be an easy task

Stable release for GTK+ is available on:

GNU/Linux and Unix
Windows (32-bit) and 64-bit

For windows
there are all-in-one bundles of the GTK+ stack including 3rd-party dependencies, both of GTK+ 2.16 and 2.20. The bundles contain both binaries and a lot of developer files, many of which are relatively irrelevant. If you intend to redistribute the GTK+ run-time, you need to figure out which files you can leave out yourself.

Download 2.20 bundle from
and extract everything under


Using CMake

CMake is a great way to generate Visual Studio 2008 solution for wxWidgets/GTK UI.
CMake GUI will help you browse for all library include path and library.
Cmake will update the build folder and cache all missing entry inside

# This is the CMakeCache file.
# For build in directory: c:/Dev/Project/Source/build
# It was generated by CMake: C:/Program Files (x86)/CMake 2.8/bin/cmake.exe
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!.
# VALUE is the current value for the KEY.

When clicking on generate a solution for your compiler EG Visual Studio 2008
will be generated. From there you can open the solution and step into wxWidget/GTK UI.
GTK offer the advantage to be stable in term of API which means that if you build a UI using GTK today it should work 5 years from now.

Project using GTK

GNOME Desktop
Maemo surf tablet
GIMP on Linux and Windows and Mac
VMWare workstation
Inkscape Graphics Editor

and earlier
GTK+ on BeOS and GTK+ using DirectFB

On the other hand Trolltek team made quite some changes between QT 3 and QT 4 which require some work to translate old code to new code. See Moving from Qt 3 to Qt 4
When starting a project from scratch QT 4 would be a good solution.


Both Qt ( and wxWidgets have many non-GUI-related classes, such as date/time, containers, networking and OpenGL functionality.
Qt4.5 is available on MS Windows, Mac, and GNU/Linux under the LGPL and under a commercial license. All ports of wxWidgets are distributed under a permissive modified (but explicitly OSI-approved) LGPL, which allows development and distribution of proprietary applications without license costs.
Qt doesn't have true native ports like wxWidgets does. What we mean by this is that even though Qt draws them quite realistically, Qt draws its own widgets on each platform. It's worth mentioning though that Qt comes with special styles for Mac OS X and MS Windows XP and Vista that use native APIs (Appeareance Manager on Mac OS X, UxTheme on Windows XP) for drawing standard widget primitives (e.g. scrollbars or buttons) exactly like any native application. Event handling, the resulting visual feedback and widget layout are always implemented by Qt.
An approach similar to Qt's is achieved with wxUniversal.
It should be noted that on KDE and Qt for Embedded Linux platforms, Qt is the native GUI library.
Qt is used by several large projects like KDE (on the other hand, wxWidgets is used by projects like the AOL Communicator)
Qt makes extremely liberal use of virtual functions (QWidget, the base class of all widgets in Qt had 51 at last count), giving it a more OO design than wxWidgets (which uses a more MFC-like approach using macros). What this means is fewer lines of code in general when using Qt, but faster execution speed when using wxWidgets (although the degree to which this occurs depends on whom you ask).
Qt is used by IBM and Borland Kylix (discontinued): this should yield more reliability. However, it is rumoured that wxWidgets will be used in the next version of C++BuilderX.
Qt has a full-featured embeddable GUI (Qt for Embedded Linux) based on GNU/Linux with framebuffer. This means that once you have Linux with /dev/fb you are ready to run examples with no additional pains. Qt for Embedded Linux has a small footprint compared with X11.
There are numerous IDEs for Qt, QtDesigner, QtCreator, QDevelop, Edyuk as well as integrations with popular IDEs such as Visual Studio, Eclipse and XCode (though there are also several IDEs for wxWidgets).
Qt offers reliable commercial support (but so does wx, see
There is nothing to stop somebody writing a Qt-based implementation of wxWidgets, though wxWidgets applications can already be made to appear Qt-ish using wxGTK and GTK-Qt (this doesn’t work too good, though).

1 comment:

Witek Baryluk said...

wxWidgets also works in Erlang, which is now recomended way of writing GUIs for Erlang.

I preffer GTK, as it works nicly in C, C#, D, Python and C++. Looks beutifully, have very good layout algorithm, and simpler abstraction of container and best automatic sizeing. It have better handling of such things like localization, accessibility. And best of all, editor: glade, which is better than anything I saw for any other toolkit (including wxWidgets and QT). GTK also do not include many unacassary wrappers, for things like files, sockets, etc (use C stdlib stupid), but still provide few usefull things like gobject model for C and XML processing and simple list container. This make gtk a toolkit of choice for me. I do not compile for Windows often, so it is not a problem for me.

Anyway wxWidgets on Unix, uses GTK anyway for rendering, so i really do not needs this indirection, and loss of many other functionalities. GTK is also supported by many companies.

As of QT, i just hate C++, and it do not work very well in D (as it is hard to interoperate C++ and D, due to the multiple inheritances in C++), so i do not use it. For plus is that QT have commericial support, and if very fast, especially when things like tree or list view have lots of entries.