tags:

views:

505

answers:

4

Put shortly: For those familiar with language bindings in Qt and Gtk+. E.g. python and ruby. Are there any quality or capability difference?

More background: I know C++ and Qt very well. Minimal experience with Gtk+. I know C++ is not ideal for language bindings due to the lack of a well defined ABI (application binary interface). I also read that Gtk+ was designed to be bound to other languages. So I wonder how this manifets itself in practice. Are the Gtk+ bindings better maintained or work better in some way than their Qt counterparts?

I am presently quite interested in the Go language, and they have started developing Gtk+ bindings. However C++ bindings is far away. It makes me wonder whether learning Gtk+ is worth it.

A: 

there are C++ gtk+ bindings. Google for gtkmm.

Wotnot
I know. I am not asking if they exist. But about their quality
Adam Smith
A: 

I have worked with both PyQt and PyGTK and I would say they're both regularly mantained and synched with their parent frameworks. However, and this is completely subjective, I found more rewarding working with PyGTK than with PyQt, even if I hadn't previously written any code using GTK. If you know well Qt, go with Qt though.

miquelramirez
+2  A: 

I think that GTK bindings are older than Qt ones (and so a bit more mature) but they are both usable and your previous knowledge of Qt should be the main factor in your choice.

I developed small GUIs using both Qt and GTK with their python bindings and found the two equivalent. Some regrets though on the PyQt bindings with Qt container (QVector, ...) that are not translated into regular python data structure and thus add a bit of complexity to the code. I didn't recall the same issues using PyGTK.

Lohrun
QVariant, and other noise is not needed, if you use PyQt with python3
pihentagy
+3  A: 

I've used GTK and Qt in C++ and also PyGTK and PyQt in Python quite extensively.

Qt beats GTK hands down - its a much more flexible, modern and clean API. GTK is also lacking some features that are important to me. From a framework point of view, I'd recommend Qt.

As for langauge bindings (I can only speak about Python, since I've never used the Ruby equivalents), I think PyGTK (using Glade and a wrapper like Padraig Bradys libglade) make GUI programming insanely easy and fun. However, if you can GPL your software (or pay the license fee), then PyQt is also a good option, and while not quite as friendly as PyGTK + Glade (in that with GTK you can define your UI in Glade as a separate XML file, so you can tweak the UI without touching code; in Qt if you want to use QtDesigner, you have to generate code using uic, if I remember correctly) the API itself is really really nice to use and mirrors the Qt frameworks clean design very closely.

Over all, I'd probably recommend using PyQt over PyGTK, but I may be biased since I much prefer Qt over GTK nowadays, though you could try both out and see which you prefer - they are both almost trivial to get working.

If you are looking for a great book on PyQt, I'd recomment Rapid GUI Programming qith Python and Qt.

To summarize: IMHO Qt beats GTK in both quality and capability. Both PyGTK and PyQt are of excellent quality and capability mirrors the underlying framework, though PyGTK can load Glade xml files.

Dan
Thanks for the input :-) Actually Qt has allowed you to save your Qt designer files as XML and load them directly for some time now. I am reading up on Gtk+ Model-View-Controller stuff. GtkTreeView etc. So far I think the design looks better than Qt's solution. But I haven't actually used it so I might be wrong. Any comments on that? Are there particular areas in Qt you find easier to work with than Gtk? E.g. layout, signal slot system, creating new widgets or just simply the fact that C++ is easier to work with than C?
Adam Smith
Interesting, when I was looking for it a while ago, I didn't find anything.. I like Qts signal-slot mechanism, its very flexible and easy to use; I really like the graphicsview system for Qt better than the GTK equivelents and I found that the Qt widget set is more complete and feature rich (eg without clunky extensions, GTK has no support for dockable windows). I do most of my work in C++ now and I find it convenient and easy (not quite as easy as Python, but close enough that I'll happily write Qt code in C++, especially drawing code, without worrying about code complexity)
Dan
Okay, interesting. I did not think of all the other APIs Qt has, like graphicsview. Which is indeed quite nice. I looked at GtkComboBox and GtkTreeView and that looked better designed than QComboBox and QTreeView. Easier to to put widgets into columns and define model. What do you mean by clunky extensions? The other GObject based APIs like Clutter etc?
Adam Smith
I cant find an example now, perhaps its improved since i looked, but I had some problems installing advanced extension widgets, especially on Windows, but even on linux. The ComboBoxes are indeed a little bit easier to use in GTK though. I've never needed to use them too much, so I don't know if Qts more complex ones are more powerful or not. I do like Qts other libraries a lot though: QtConcurrent, QtWebkit, Graphics View and QtNetwork especially. I guess some people would prefer not to have a framework bundle _too_ much, but I like it in Qts case.
Dan