What should I choose: GTK+ or Qt?

Idan picture Idan · Dec 11, 2009 · Viewed 86.2k times · Source

Can someone suggest what's the best uses for those libraries today? Is it just GUI, or do they have database, XML, networking, threading, etc support too?

I was reading about them, and considered starting to learning/using one of them.

What is the most common one? What's the difference between them? Why would you choose one over the other?

Answer

Gregory Pakosz picture Gregory Pakosz · Dec 11, 2009

As you seem to primarily target Linux, then the choice mostly depends on the programming language you want to use.

If you code in C, then obviously go for GTK+

If you code in C++, go for Qt, otherwise you will need Gtkmm (a C++ wrapper over GTK+)

If you code in Python, both GTK+ and Qt have bindings for the language: see PyGtk, PyQt and PySide (the one launched by Nokia themselves).

If you code in Java, Qt is no more a viable option imho as Nokia discontinued Qt Jambi (the Java bindings for Qt).

Also, Qt is more top-notch regarding its scenegraph QGraphicsScene API, its scripting engine built over Javascript Core (the engine powering WebKit), its state machine and animations framework, and the declarative UI.

GTK+ doesn't offer that much although you can use Clutter alongside with it.

If you're specifically looking into DB, XML (GTK+ has a parser for a subset of XML) and threading (GTK+ has GLib) features then Qt will offer all that in QtSql, QtXml and QtConcurrent.

All in all, I would say Qt is a sure choice. But GTK+ is very capable as well.

I'm not sure you will get a crystal clear answer for your question, which explains why some people keep preferring Gnome over KDE or vice-versa. Choose what works best for you.

PS: I you plan to also target Symbian, then go for Qt.

EDIT: Something that is also great with Qt is QtWebView: it brings Chromium into your Qt application to display web content. Others are embedding web content into their application using for instance Awesomium or Berkelium.