본문 바로가기

Programming/Python Program

GTK VS Qt in Python Development Frameworks.

        

GTK vs Qt

GTK+ and Qt are open-source cross-platform User Interface toolkits and development frameworks. These are the two most popular frameworks in use for GNU/Linux and BSD because they are open-source and give developers a powerful toolkit to design Graphical User Interfaces. GTK+ is used as the standard toolkit for the GNOME and Xfce Desktop Environments while Qt is used for KDE Plasma and LXQt.

Development

Qt is developed by an open community around Qt Project, with main developers being Digia, KDE and many other users of Qt. Qt development team was originally known as Trolltech, then acquired by Nokia in 2008 and known as Qt Software.

GTK+ was originally created to develop the GIMP graphical application and is now developed and maintained by the GNOME Foundation.

Usability

Qt was designed from the ground up with object-orientation in mind. It uses a code generator called moc and uic to deliver features at higher level than those available in C++ (signals, slots, object introspection, scriptability, GUI integration).

GTKmm, the C++ interface to GTK+, uses standard C++ templates. Unlike Qt APIs, GTKmm has been added on top GTK+ and thus was not designed from the ground up. Because of this, it is said that GTKmm reflects some design decisions seen in the GTK+'s API for C.

Documentation

There is extensive documentation for Qt at the QtProject website.

GTK+ has documentation available both online and locally using the DevHelp system.

Framework

Both Qt and GTK+ were developed from the ground up with Object Oriented Programming in mind. Qt is developed in C++, GTK in C in an object oriented manner using the GObject type system. C++ bindings are available through gtkmm.

Coverage

Qt is a complete consistent framework. You can easily connect HTTP events to GUI elements, fill forms with results from a database query or build an interactive visualization of large datasets. Qt 4 modules include QtCore, QtGui, QtMultimedia, QtNetwork, QtOpenGL, QtOpenVG, QtScript, QtScriptTools, QtSql, QtSvg, QtWebKit, QtXml QtXmlPatterns, QtDeclarative, Phonon, Qt3Support. Modules for working with Qt tools are QtDesigner, QtUiTools, QtHelp, QtTest. Modules for Windows developers are QAxContainer, QAxServer. Module for Unix developers is QtDBus.

GTK+ is only a GUI toolkit, but can be seen as part of a GObject based library stack. It interoperates very well with other libraries such as GLib, GIO, GNet, GStreamer, Poppler, Pango, Cairo and Clutter.

Portability

Both Qt and GTK+ are available on most popular desktop Operating Systems. For mobile devices, Qt for Embedded allows Qt to run directly on the hardware, without the need of X11 or a window manager. The first Qt application started becomes the window manager featuring full composition and top-level transparency. GTK+ on embedded devices (e.g. Meego) requires an X11 server + window manager, resulting in at least three processes running for a hello world application.

OSQtGTK+
Windows XP, Vista, 7NativeNative
Windows Mobile (CE)NativeNot available
Mac OSXNativeNative [1]
Linux/Unix (X11)NativeNative
Linux/Unix (framebuffer)NativeNative [2]
Linux/Unix (eglfs)NativeNot available (GNOME extension exists [3])
VxWorksNativeNot available
Symbian (S60 3rd edition and later)NativeNot available
maemo 6 (Harmattan)NativeNot available[4]
WebOSNativeNot available
AndroidNativeNot available
iOSNativeNot available
BlackBerry 10NativeNot available
Ubuntu TouchNativeIn development
SailFish OSNativeNot available
AmigaOSNative [5]Not available
eComstation (os/2)NativeOutdated
HaikuNativeNot available

Qt GUIs look and behave more natively than GTK+ GUIs on Windows and Mac platforms. This is because Qt calls native painting primitives whenever possible and practical, but the native support is wrapped within just another style. Even so, neither Qt nor GTK+ will look and feel completely native on Windows or Mac because this is not feasible when portability is one of the design goals. A non-native OS-independent user experience can be achieved with both toolkits by setting one of their portable widget styles.

Ported projects

A lot of projects take on the extra work and port their existing apps to another toolkit.

From Qt to GTK+

No known projects yet.

From GTK+ to Qt

Apps: Musesore, Frescobaldi, Wireshark, Subsurface, VLC media player, Gcompris, Mkvtoolnix, Dropbox, Megaglest (Map editor) | Ports in progress: OpenShot, ufw-frontends

Desktop Environments: Unity 2D and LXQt | Ports in progress: Unity 8

Performance

Both toolkits use similar amount of memory and CPU for similar tasks when traditional widgets are used. Differences demonstrated in old analysis come from the usage of old compilers or specific setups so are no longer valid. GTK+ has no equivalent of QML APIs, runtime and tools. QML outperforms GTK+ widgets in terms of performance of animations and transitions.

Native Languages and Language bindings

Natively, Qt has C++ based libraries. Its QML module natively supports QML (Qt Modelling Language) for components creation. Many language bindings are delivered thanks to the SMOKE introspective wrapper. Qt supports Java (officially supported in the past, but not anymore [6]), Perl [7], Python [8] [9], PHP [10], and Ruby [11] based development. Qt 4 also ships with the embedded scripting language QtScript, which is an ECMA-Script (JavaScript) implementation. QML from Qt 5 ships Google's V8 JavaScript engine.

Natively, GTK+ has C based libraries. It supports several languages, notably including C++ [12], Java [13], Perl [14], Python [15], PHP [16], Ruby [17], Vala [18], JavaScript [19], and Mono/C# [20].

GObject libraries, the base for GTK+, have a tool to allow them to be available to any language supporting GObject-Introspection. Any library with a new release, can install its GIR (XML format) and Typelib files, to be available for bindings with no extra effort and by-hand created binding.

GTK+ applications can also be developed with Vala, an object oriented programming language similar to C#, specially designed for the GObject type system. Vala programs compile to C code, without imposing any additional runtime requirements and without using a different API compared to applications and libraries written in C.

Python bindings: Mature and actively-developed LGPL bindings exist for both GTK+ (PyGTK and PyGObject) and Qt (PySide, PyQt). PySide was funded by Nokia to provide free bindings (mostly) compatible with the more restrictively, GPL-licensed free version of PyQt. PySide is now part of the Qt Project. Binaries are available for GNU/Linux, OS X and Windows.

Rivalries

A good example is when Nokia (previously focused on GTK+) announced that it will increase co-operation with Trolltech (Qt)[21]. Motorola representatives announced they will focus more on the GTK+ toolkit [22] but that development has come to a stop.

In 2008, Nokia acquired Trolltech to obtain premium support in Qt for Nokia's (then-emerging) mobile platforms such as new Symbian and maemo/MeeGo Harmattan, ditching GTK (and in the case of Symbian a home-grown toolkit) as the main development library for these devices. In 2009, Nokia adopted the LGPL for Qt. In 2011 qt-project.org went public with open collaboration and meritocracy rules, bringing its governance and licensing to the same level as GTK. The sales of the Qt department in Nokia (with the trademark and most developers) to Digia has so far not impacted this and development has picked up steam.

Thanks to the advanced features of Qt5 (especially QML) and GTK development being in flux and very strongly focused around the needs of GNOME, various third party projects are moving over to Qt5. Ubuntu builds on Qt and QML for Ubuntu Phone and will move over the desktop in the future, the LXDE desktop and GCompris projects are the process of porting over and Subsurface (a project which famously has Linus Torvalds as core contributor) has had its first Qt based release. LXDE provides extensive tips on the migration process.

Size of development teams

According to Ohloh, GTK has about 210 contributors adding around 3000 commits a year. Qt, with the development focus moving from Qt4 to Qt5 and having introduced open governance only in 2011, is a bit harder to measure. Qt4, in maintenance, sports a contributor number comparable to GTK, but has only about 1700 commits in the last 12 months. Development has clearly moved to Qt5 where the over 400 contributors committing 15780 commits in the last year reflects the fact that the majority of Qt developers work full-time on the tool kit, while GTK+ depends more strongly on volunteer contributions.

During the year, GTK hovers around 25 contributors per month, Qt5 has a little over active 100 coders adding their change sets in the same time, contradicting the starkly negative wake-up call GTK maintainer Benjamin Otte wrote claiming that GNOME has 20 core hackers at most and GTK is down to one paid developer — himself. Both tool kits are still actively maintained and developed and also have many non-core libraries providing additional features and functionality to the ecosystem, with GTK building on glib, Clutter and more while Qt stands to benefit from the work in splitting off the KDE Libraries to stand-alone, reusable parts with minimal dependencies in KDE's Frameworks 5 efforts.

Licenses

Both Qt and GTK+ are under the LGPL. This means that they can also be used by closed source applications in environments which support dynamic linking or relinking static libraries. Additionally, Qt has (within Qt Project) an agreement with Digia, who provide Qt under the terms of a commercial licensing agreement. This version of Qt is called Qt Commercial. This version allows Qt to be extended and merged into closed source code without releasing the code.

Links